Java中使用通配符配置struts文件<单通配符和双通配符>

来源:互联网 发布:网络配音兼职 编辑:程序博客网 时间:2024/05/22 00:23

//使用Method--指明action类中具体方法名配置方法

<packagename="purview"namespace="/purview"extends="struts-default">

<actionname="gotoPurviewPage"class="purviewAction"method="gotoPurviewPage">

<resultname="success">/WEB-INF/basic/purview/purviewList.jsp</result>

</action>

<actionname="getNodes"class="purviewAction"method="getNodes"/>

<actionname="saveOrEditPurview"class="purviewAction"method="saveOrEditPurview"/>

<actionname="getPurviewObject"class="purviewAction"method="getPurviewObject"/>

<actionname="delPurview"class="purviewAction"method="delPurview"/>

</package>


//举个列子----单通配符-模糊方法名

<?xmlversion="1.0"encoding="UTF-8"?>

<!DOCTYPE strutsPUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN""http://struts.apache.org/dtds/struts-2.1.dtd">

<struts>

<packagename="template"namespace="/template"extends="struts-default">

<actionname="*"class="templateAction"method="{1}">

<resultname="showIndex">${relativeHtmlPathName}</result>

<resultname="templateManager">/WEB-INF/page/back/template/templateManager.jsp</result>

<resultname="editFtl">/WEB-INF/page/back/template/editftl.jsp</result>

<resultname="saveFtl"type="chain">templateManager</result>

<resultname="deleteTemplate"type="chain">templateManager</result>

<resultname="addTemplate"type="chain">templateManager</result>

<resultname="toAddTemplate">/WEB-INF/page/back/template/addFtl.jsp</result>

</action>

</package>

</struts>


//双通配符配置方法

<packagename="topic"namespace="/topic"extends="struts-default">

    <actionname="*_*"class="topicAction"method="{2}">

<resultname="success"type="redirect">find_selAllTopic.action</result>

<resultname="saveBefore">/WEB-INF/page/back/topic/addTopic2.jsp</result>

<resultname="selAllTopic">/WEB-INF/page/back/topic/selTopic2.jsp</result>

<resultname="findTopicById">/WEB-INF/page/back/topic/addTopic2.jsp</result>

<resultname="sellAll">/WEB-INF/page/back/topic/selTopic2.jsp</result>

<resultname="sellAllByName">/WEB-INF/page/back/topic/selTopic2.jsp</result>

<resultname="sellAllBySubject">/WEB-INF/page/back/topic/selTopic2.jsp</result>

<resultname="error">/WEB-INF/page/back/examtype/error.jsp</result>

</action>

</package>



0 0
原创粉丝点击