ITeye博客

Struts2后缀-深入Struts2

cakin24 · 2017-10-21 07:44 · Struts · 编程语言 · Markdown

一 将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中配置

 

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。