七、struts2后缀

六、struts2后缀

  1.一般情况下,访问helloworld这个action,需要我们url地址为xxx/helloworld.action或者xxx/helloworld,默认为action后缀和无后缀

  2.如果希望改成.do的形式

    2.1 方法1,struts.xml中

<constant name="struts.action.extension" value="do"></constant>

    2.2方法2,web.xml中(这个方法我没有试成功)

<filter>
      <filter-name>struts2</filter-name>
      <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
      <init-param>
          <param-name>do</param-name>
          <param-value>struts.action.extension</param-value>
      </init-param>
  </filter>
原文地址:https://www.cnblogs.com/myz666/p/8454302.html