struts2学习记录
2014-12-30 21:46
281 查看
1. 拷贝必须的jar文件.直接拖动到WebRoot/WEB-INF/lib下
commons-fileupload-1.2.1.jar
commons-io-1.3.2.jar
freemaker-2.3.16.jar
javassist-3.7.ga.jar
ognl-3.0.jar
struts2-core-2.2.1.jar
xwork-core-2.2.1.jar
2. web.xml进行配置
3.struts.xml的配置,注意不是struts2.xml,在src/目录下,编译时自动拷贝到WEB-INF/classes文件下
4.访问路径为http://localhost:8080/工程名/页面名
页面名(login.jsp)
commons-fileupload-1.2.1.jar
commons-io-1.3.2.jar
freemaker-2.3.16.jar
javassist-3.7.ga.jar
ognl-3.0.jar
struts2-core-2.2.1.jar
xwork-core-2.2.1.jar
2. web.xml进行配置
<?xml version="1.0" encoding="GBK"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"> <!-- 定义Struts2的核心Filter --> <filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.ng.filter. StrutsPrepareAndExecuteFilter</filter-class> </filter> <!-- 让Struts2的核心Filter拦截所有请求 --> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> </web-app>
3.struts.xml的配置,注意不是struts2.xml,在src/目录下,编译时自动拷贝到WEB-INF/classes文件下
<?xml version="1.0" encoding="GBK"?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1.7//EN" "http://struts.apache.org/dtds/struts-2.1.7.dtd"> <!-- 指定Struts 2配置文件的根元素 --> <struts> <!-- 指定全局国际化资源文件 --> <constant name="struts.custom.i18n.resources" value="mess"/> <!-- 指定国际化编码所使用的字符集 --> <constant name="struts.i18n.encoding" value="GBK"/> <!-- 所有的Action定义都应该放在package下 --> <package name="lee" extends="struts-default"> <action name="login" class="org.crazyit.app.action.LoginAction"> <!-- 定义三个逻辑视图和物理资源之间的映射 --> <result name="input">/login.jsp</result> <result name="error">/error.jsp</result> <result name="success">/welcome.jsp</result> </action> </package> </struts>
4.访问路径为http://localhost:8080/工程名/页面名
页面名(login.jsp)
相关文章推荐
- struts2的dojo插件一些学习记录
- Struts2学习记录(Struts2各项配置文件解析)
- Struts2学习记录2(ValueStack(值栈)和ognl)
- struts2学习记录
- Struts2_struts2学习记录
- struts2视频学习错误记录1-7讲
- 【JavaEE企业应用实战学习记录】struts2实现登录并获取各个范围的数据
- 【JavaEE企业应用实战学习记录】struts2登录
- struts2 学习记录
- struts2 标签学习记录(一)
- Struts2 学习记录(4)
- Struts2学习记录1
- 【ssh2学习记录】4、struts2验证框架内置校验器列表
- Struts2学习记录(1)
- Struts2 学习记录(3)
- Struts2的输入校验流程(学习记录)
- Struts2学习记录
- Struts2 学习记录-1--Struts2中的配置文件
- 学习Struts2的记录
- Struts2 学习记录(2)