Struts2后缀-深入Struts2

来源:互联网 发布:数据透视表 总计图标 编辑:程序博客网 时间:2024/05/21 22:58
一 将action后缀变成html后缀
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd";>
<struts>
        <include file="helloworld.xml"></include>
        <constant name="struts.action.extension" value="html"></constant>
        <constant name="struts.enable.DynamicMethodInvocation" value="false"></constant>
</struts> 
 
二 测试


 
 
三 去掉action后缀
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd";>
<struts>
        <include file="helloworld.xml"></include>
        <!-- 如果不配置下面这句话,也可以去掉后缀访问-->
        <constant name="struts.action.extension" value=""></constant>
        <constant name="struts.enable.DynamicMethodInvocation" value="false"></constant>
</struts>
 
四 测试


 
 
五 配置后缀的三种方式
1、在struts.xml中配置
<constant name="struts.action.extension" value="html"></constant>
2、在struts.properties中配置,而且可以配置多个后缀
struts.action.extension=action,do,struts2,
3、在web.xml中配置

 



 
  • 大小: 19.4 KB
  • 大小: 19.1 KB
  • 大小: 123.8 KB
  • 查看图片附件
原创粉丝点击