配置Struts2项目
来源:互联网 发布:linux命令行编辑文件 编辑:程序博客网 时间:2024/05/21 01:44
参看了官方strust2-blank.war包里面的jar包,以及配置文件。
导入jar包
新建struts.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
<constant name="struts.enable.DynamicMethodInvocation" value="true" />
<constant name="struts.devMode" value="true" />
<constant name="struts.i18n.encoding" value="UTF-8"></constant>
<constant name="struts.multipart.maxSize" value="104857600"/><!-- 100M -->
<!--配置临时文件存放目录 -->
<constant name="struts.multipart.saveDir" value="/tmp"/>
<!-- 配置后缀, 可以使用无后缀,sdo -->
<constant name="struts.action.extension" value="action,sdo" />
<package name="default" namespace="/" extends="struts-default,json-default">
<default-action-ref name="index" />
<global-results>
<result name="error">/error.jsp</result>
</global-results>
<global-exception-mappings>
<exception-mapping exception="java.lang.Exception" result="error"/>
</global-exception-mappings>
</package>
<include file="mystruts.xml"/>
<!-- Add packages here -->
</struts>
上面的文件引入了mystruts.xml,则
新建mystruts.sml
<?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="admin" namespace="/admin" extends="default">
<!--用户管理-->
<action name="user" class="com.mckj.xzly.action.UserAction">
<result name="login_success">/WEB-INF/admin/index.jsp</result>
<result name="login_error">/login.jsp</result>
<result name="success">/index.jsp</result>
</action>
</package>
<!-- 前台页面路径的包名 -->
<package name="index" namespace="/index" extends="default">
<action name="index" class="com.mckj.xzly.action.IndexAction">
<result name="success">/index.jsp</result>
</action>
</package>
</struts>
新建web.xml文件
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" 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_3_0.xsd">
<display-name></display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<filter>
<filter-name>struts2</filter-name>
<filter-class>com.mckj.xzly.util.MyStrutsFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<session-config>
<session-timeout>20</session-timeout>
</session-config>
<error-page>
<error-code>404</error-code>
<location>/error/error404.jsp</location>
</error-page>
<error-page>
<error-code>500</error-code>
<location>/error/error500.jsp</location>
</error-page>
<security-constraint>
<web-resource-collection>
<web-resource-name>fortune</web-resource-name>
<url-pattern>/*</url-pattern>
<http-method>PUT</http-method>
<http-method>DELETE</http-method>
<http-method>HEAD</http-method>
<http-method>OPTIONS</http-method>
<http-method>TRACE</http-method>
</web-resource-collection>
<auth-constraint></auth-constraint>
</security-constraint>
<login-config>
<auth-method>BASIC</auth-method>
</login-config>
</web-app>
注:此处可供下载demo项目,仅供学习参考 http://download.csdn.net/detail/ergouge/9100207
0 0
- struts2项目简单配置
- Struts2项目配置
- 配置Struts2项目
- Struts2项目简单配置
- 如何手动配置Struts2项目
- 在Eclipse中配置Struts2项目
- 在Eclipse中配置Struts2项目
- 自我研究Struts2项目的开发配置
- Struts2笔记之项目环境配置<一>
- Struts2项目在MyEclipse中的配置
- 如何搭建以及配置Struts2项目
- Struts2配置描述及项目走向流转
- struts2项目中web.xml配置
- struts2源码研究(一)------配置struts2源码项目
- Struts2的Annotation使用 实现 struts2 “零配置”项目
- 在Eclipse中配置Struts2项目(一)
- 在Eclipse中配置Struts2项目(二)
- 在Eclipse中配置Struts2项目(三)
- 真机调试注意点
- 【视频处理】YUV格式说明
- 《剑指offer》丑数
- Maximum Subarray
- lintcode-哈稀函数-128
- 配置Struts2项目
- TextView 显示html文本
- 免费MATLAB替代品winpython
- java中的异常(Exception)介绍
- 出自ios深入浅出专栏(内购)
- [LeetCode-21] Merge Two Sorted Lists(合并两个有序链表)
- instanceof
- 教你如何减少家用电器的辐射
- 顺序链表类模板的实现