struts2.2.1配置详解
2010-10-27 09:08
441 查看
1、下载 struts.2.2.1 下载地址自己baidu.com去。
2、打开struts2-2.2.1-all/struts-2.2.1/lib/ 目录,复制
打开struts2-2.2.1-all/struts-2.2.1/apps/ 目录下随便一个.war 文件 用解压软件
找到 javassist.jar 和上面找到的 .jar 文件一起复制到 WEB-INF/lib 下。
3、修改 WEB-INF/web.xml
<?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">
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<filter>
<filter-name>struts22</filter-name>
<filter-class>
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts22</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
4、在src 下创建 strust.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="struts2" extends="struts-default">
<action name="login" class="org.test.action.LoginAction" >
<result name="success">/result.jsp</result>
</action>
</package>
</struts>
5、修改 tomcat/conf/server.xml
添加:<Context path="/struts22" docBase="d:/www/java/struts22/WebRoot" />
创建jsp文件测试
index.jsp
---------------------------------------------------------
<body>
<form method="POST" action="login.action">
userName :<input type="text" name="username" />
password :<input type="text" name="password" />
age :<input type="text" name="age" />
<input type="submit" value="login" />
</form>
</body>
-------------------------------------------------------------
result.jsp
<body>
userName : ${requestScope.username }
password : ${requestScope.password }
age : ${requestScope.age }
</body>
---------------------------------------------------------------
测试地址:http://localhost:8080/struts22/
结果:userName : password : 11111111 age : 111111
2、打开struts2-2.2.1-all/struts-2.2.1/lib/ 目录,复制
打开struts2-2.2.1-all/struts-2.2.1/apps/ 目录下随便一个.war 文件 用解压软件
找到 javassist.jar 和上面找到的 .jar 文件一起复制到 WEB-INF/lib 下。
3、修改 WEB-INF/web.xml
<?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">
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<filter>
<filter-name>struts22</filter-name>
<filter-class>
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts22</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
4、在src 下创建 strust.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="struts2" extends="struts-default">
<action name="login" class="org.test.action.LoginAction" >
<result name="success">/result.jsp</result>
</action>
</package>
</struts>
5、修改 tomcat/conf/server.xml
添加:<Context path="/struts22" docBase="d:/www/java/struts22/WebRoot" />
创建jsp文件测试
index.jsp
---------------------------------------------------------
<body>
<form method="POST" action="login.action">
userName :<input type="text" name="username" />
password :<input type="text" name="password" />
age :<input type="text" name="age" />
<input type="submit" value="login" />
</form>
</body>
-------------------------------------------------------------
result.jsp
<body>
userName : ${requestScope.username }
password : ${requestScope.password }
age : ${requestScope.age }
</body>
---------------------------------------------------------------
测试地址:http://localhost:8080/struts22/
结果:userName : password : 11111111 age : 111111
相关文章推荐
- MyEclipse 中配置struts2.2.1的方法
- [整理]struts2.0中struts.xml配置文件详解
- struts2学习笔记--struts.xml配置文件详解
- Struts配置文件详解
- struts2.0中struts.xml配置文件详解【转】
- struts.properties配置详解
- struts.xml配置详解
- Struts-config.xml配置文件《action-mappings》元素的详解
- struts2配置详解(struts.xml配置详解)
- struts-validate.xml配置详解demo
- struts2.2.1+spring 3.0.3+hibernate3.6+dwr3.0全注解整合详解
- struts2中struts.xml配置文件详解
- struts.xml 配置详解之六 通配符
- Struts 2中的constant配置详解
- struts.xml配置详解
- struts2.0 struts.xml配置文件详解
- struts2中struts.xml配置文件详解【未整理】
- struts.properties配置详解
- struts2的struts.properties配置文件详解
- struts2的struts.properties配置文件详解