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>
<constant name="struts.custom.i18n.resources" value="message"></constant>
<constant name="struts.multipart.saveDir" value="c:\"></constant>
<package name="struts2" extends="struts-default">
<global-results>
<result name="global-exception">/global_exception.jsp</result>
</global-results>
<global-exception-mappings>
<exception-mapping result="global-exception" exception="java.lang.Exception"></exception-mapping>
</global-exception-mappings>
<!--
<interceptors>
<interceptor name="myInterceptor" class="com.test.interceptor.MyInterceptor">
<param name="hello">world</param>
</interceptor>
<interceptor name="myInterceptor2" class="com.test.interceptor.MyInterceptor2">
</interceptor>
<interceptor name="myInterceptor3" class="com.test.interceptor.MyInterceptor3">
</interceptor>
<interceptor name="auth" class="com.test.interceptor.AuthInterceptor">
</interceptor>
<interceptor-stack name="myStack">
<interceptor-ref name="myInterceptor"></interceptor-ref>
<interceptor-ref name="myInterceptor2"></interceptor-ref>
<interceptor-ref name="defaultStack"></interceptor-ref>

</interceptor-stack>
</interceptors>

<default-interceptor-ref name="myStack"></default-interceptor-ref>
-->
<global-results>
<result name="login" type="redirect">/login2.jsp</result>
<result name="passwordInvalid">/passwordInvalid.jsp</result>
</global-results>


<global-exception-mappings>
<exception-mapping result="passwordInvalid" exception="com.test.exception.PasswordException"></exception-mapping>
</global-exception-mappings>

<action name="login" class="com.test.action.LoginAction">
<exception-mapping result="usernameInvalid" exception="com.test.exception.UsernameException"></exception-mapping>
<result name="success">/result.jsp</result>
<result name="usernameInvalid">/usernameInvalid.jsp</result>
</action>

<action name="pointConverter" class="com.test.action.PointAction">
<result name="success">/output.jsp</result>
<result name="input">/input.jsp</result>
</action>

<action name="register" class="com.test.action.RegisterAction">
<result name="success">/success.jsp</result>
<result name="input">/register2.jsp</result>
<result name="invalid.token">/register2.jsp</result>

<interceptor-ref name="token"></interceptor-ref>
<interceptor-ref name="defaultStack"></interceptor-ref>
<!--

<interceptor-ref name="auth"></interceptor-ref>
<interceptor-ref name="defaultStack"></interceptor-ref>
<interceptor-ref name="myInterceptor3">
<param name="excludeMethods">test,execute</param>
<param name="includeMethods">test</param>
</interceptor-ref>
<interceptor-ref name="defaultStack"></interceptor-ref>
-->
</action>
<action name="upload" class="com.test.action.UploadAction">
<result name="success">/uploadResult.jsp</result>
<result name="input">/upload.jsp</result>
<interceptor-ref name="fileUpload">
<param name="maximumSize">409600</param>
<param name="allowedTypes">application/vnd.ms-powerpoint</param>
</interceptor-ref>
<interceptor-ref name="defaultStack"></interceptor-ref>
</action>

<action name="download" class="com.test.action.DownloadAction">
<result name="success" type="stream">
<param name="contentType">application/vnd.ms-powerpoint</param>
<param name="contentDisposition">filename="Struts2.ppt"</param>
<param name="inputName">downloadFile</param>
</result>
</action>
</package>

</struts>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值