美文网首页
Struts2.5动态方法调用struts.xml的配置

Struts2.5动态方法调用struts.xml的配置

作者: nhfc99 | 来源:发表于2017-06-01 11:30 被阅读0次

    通过格式:actionName!methodName.action
    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.5//EN"
    "http://struts.apache.org/dtds/struts-2.5.dtd">
    <struts>
    <constant name="struts.devMode" value="true" />
    <constant name="struts.enable.DynamicMethodInvocation" value="true" />
    <package name="default" extends="struts-default" namespace="/">
    <action name="userInfo" class="UserInfoAction" method="execute">
    <result name="success">success.jsp</result>
    <result name="error">error.jsp</result>
    <result name="doit">success.jsp</result>
    <allowed-methods>doit</allowed-methods>
    </action>
    </package>
    </struts>

    通过指定方法:
    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.5//EN"
    "http://struts.apache.org/dtds/struts-2.5.dtd">
    <struts>
    <package name="nhf" extends="struts-default" namespace="/nhfc99">
    <action name="nhf" class="com.nhfc99.actions.NhfAction" method="execute">
    <result name="success">${pageContext.request.contextPath}/success.jsp
    </result>
    <result name="deal">${pageContext.request.contextPath}/method/deal.jsp
    </result>
    <allowed-methods>deal</allowed-methods>
    </action>
    <action name="edit" class="com.nhfc99.actions.NhfAction"
    method="edit">
    <result name="edit">${pageContext.request.contextPath}/method/edit.jsp
    </result>
    </action>
    </package>
    </struts>

    相关文章

      网友评论

          本文标题:Struts2.5动态方法调用struts.xml的配置

          本文链接:https://www.haomeiwen.com/subject/wfnsfxtx.html