struts2框架namespace属性与form表单的配置问题

最近在学struts2框架的时候,被配置文件弄得有点头疼,发现同样一个package下的Action用户可以通过form表单的多种配置进行访问,头大!为此特意写了一个小总结,以防以后再次用到!刚学不久,哪边有错,还请大佬们斧正!这里主要就谈namespace与form表单之间的配置关系:

首先我们先将问题划分为两类:

一:在package中设置了namspace属性的
    struts.xml中的配置如下
    <package name="struts2" namesapce="/struts2" extends="struts-default">
        <action name="reguser" class="action.RegAction" method="regUser">
            <result name="ok">/success.jsp</result>
            <result name="error">/error.jsp</result>
        </action>
    </package>
    对应的form表单中可以有如下几种写法:
    使用struts2框架:
    <s:form action="reguser" namespace="/struts2" method="post">
        <s:textfield name="

猜你喜欢

转载自blog.csdn.net/qq_41134622/article/details/80329771