struts2HelloWorld
来源:互联网 发布:java面试项目经历 编辑:程序博客网 时间:2024/06/11 14:17
</pre>第一步:</p><p>新建一个java web project 取名为 Struts2HelloWorld。</p><p>第二步:</p><p>下载struts2所需jar包:下载<span style="color:rgb(64,50,38); font-family:verdana,'ms song',宋体,Arial,微软雅黑,Helvetica,sans-serif; font-size:14px; line-height:24px">Struts-2.1.6.zip,解压得到lib目录下所有jar包。</span></p><p><span style="color:rgb(64,50,38); font-family:verdana,'ms song',宋体,Arial,微软雅黑,Helvetica,sans-serif; font-size:14px; line-height:24px">第三步:</span></p><p><span style="color:rgb(64,50,38); font-family:verdana,'ms song',宋体,Arial,微软雅黑,Helvetica,sans-serif; font-size:14px; line-height:24px">将第二步得到的jar包复制到Struts2HelloWorld工程lib目录下并导入。</span></p><p><span style="color:rgb(64,50,38); font-family:verdana,'ms song',宋体,Arial,微软雅黑,Helvetica,sans-serif; font-size:14px; line-height:24px"><img src="" alt="" /><img src="http://img.blog.csdn.net/20140522151947968?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvbGNfODgwNjI3/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="" /></span></p><p><span style="color:rgb(64,50,38); font-family:verdana,'ms song',宋体,Arial,微软雅黑,Helvetica,sans-serif; font-size:14px; line-height:24px"><img src="" alt="" /></span></p><p><span style="color:rgb(64,50,38); font-family:verdana,'ms song',宋体,Arial,微软雅黑,Helvetica,sans-serif; font-size:14px; line-height:24px">第四步:</span></p><p><span style="color:rgb(64,50,38); font-family:verdana,'ms song',宋体,Arial,微软雅黑,Helvetica,sans-serif; font-size:14px; line-height:24px">新建/修改web.xml:若原工程没有web.xml,那么在WEB-INF目录下新建一个。</span></p><p><span style="color:rgb(64,50,38); font-family:verdana,'ms song',宋体,Arial,微软雅黑,Helvetica,sans-serif; font-size:14px; line-height:24px"><img src="" alt="" /></span></p><p>web.xml中的代码为:</p><p></p><pre code_snippet_id="358283" snippet_file_name="blog_20140522_1_6238181" name="code" class="html"><?xml version="1.0" encoding="UTF-8"?><web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"><filter><filter-name>struts2</filter-name><filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class></filter><filter-mapping><filter-name>struts2</filter-name><url-pattern>/*</url-pattern></filter-mapping><welcome-file-list><welcome-file>index.jsp</welcome-file></welcome-file-list></web-app>
第五步:
创建工程包com.test.struts并创建创建struts.xml:
第六步:
复制代码
<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"><struts><package name="default" namespace="/" extends="struts-default"><action name="hello"><result>/Hello.jsp</result></action></package></struts>
到struts.xml中。
第七步:
新建Hello.jsp
复制代码
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"pageEncoding="ISO-8859-1"%><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Insert title here</title></head><body>Hello Struts2!</body></html>到Hello.jsp中。
第八步:
将Struts2HelloWorld部署到本地Tomcat中,浏览器访问
http://localhost:8080/Struts2HelloWorld/hello
显示
0 0
- struts2HelloWorld
- 1.struts2HelloWorld
- Struts2HelloWorld例子编写步骤
- C++ 操作符函数
- 华为的JAVA面试题及答案(部分)
- MVC里面布局你们具体如何整,求帮
- 关于定时器NSTime与滚动视图一块运用
- Bluetooth LE(低功耗蓝牙) - 第三部分
- struts2HelloWorld
- PAT 1005 继续(3n+1)猜想
- Linux使用PAM锁定多次登陆失败的用户(含重置错误次数)
- android:windowSoftInputMode属性详解
- Nginx 关于 Rewrite 执行顺序详解
- jboss4.2.3更改端口和默认根应用程序
- c#生成不重复的字符串
- CCControlExtension/CCControlButton
- [C++ GUI Programming with Qt 4/5 代码] && [从Qt4过渡至Qt5(The Transition from Qt 4.x to Qt 5)]