struts2配置

<?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>
  <!-- http:localhost:端口号/demo/download -->
  <!-- json-default继承struts-defalut action中name表示请求路径 ,result中name表示返回视图ID -->
  <package name="demo" namespace="/demo" extends="json-default">
    <action name="download" class="photoAction">
      <result name="one" type="stream">
        <param name="contentType">image/png</param>
        <param name="contentDisposition">attachment;filename="mylove.png"</param>
        <!-- in是photoAction的一个Bean属性,其类型必须是inputStream类型 -->
        <param name="inputName">photo</param>
      </result>
  </action>

  <action name="photo" class="photoAction">
    <result name="one" type="stream">
      <param name="contentType">image/png</param>
      <!-- in 是photoAction的一个Bean属性,其类型必须是 InputStream类型 -->
       <param name="inputName">photo</param>
    </result>
  </action>

  <action name="excel" class="excelAction">
    <result name="one" type="stream">
      <param name="contentType">application/vnd.ms-excel</param>
      <param name="inputName">excel</param>
    </result>
  </action>

  <action name="test" class="redirectAction">
    <result name="doc" type="redirect">http://doc.tedu.cn</result>
    <result name="photo" type="redirectAction">demo/photo</result>
  </action>
</package>

  <package namespace="/test" name="test" extends="json-default">
    <!-- 拦截器 -->
    <interceptors>
      <interceptor name="demoInc" class="demoInterceptor"></interceptor>
      <interceptor-stack name="mystack">
        <interceptor-ref name="basicStack"></interceptor-ref>
        <interceptor-ref name="demoInc"></interceptor-ref>
      </interceptor-stack>
    </interceptors>

  <action name="test" class="demoAction">
    <interceptor-ref name="demoInc"></interceptor-ref>
    <result name="one">/WEB-INF/one.jsp</result>
    <result name="two">/WEB-INF/two.jsp</result>
  </action>

  <action name="stack" class="stackAction">
    <result name="three">/WEB-INF/three.jsp</result>
  </action>
</package>

</struts>

 

class引用的是spring注解标记的ID,如果未采用spring,须填写类的全名(包名+类名)

posted on 2017-01-23 09:48  xyz23  阅读(110)  评论(0编辑  收藏  举报

导航