正确的做法:
<s:form action="hello" method="post" namespace="/xiva" name="hello">
<s:label>输入内容:</s:label><s:textfield name="msg"></s:textfield>
<s:submit value="submit"></s:submit>
</s:form>
<package name="demo" namespace="/xiva" extends="struts-default">
<action name="hello" class="org.xiva.struts2.demo.HelloAction">
<result name="suc">/hello.jsp</result>
<result name="fal">/errors.jsp</result>
</action>
</package>
错误的不给出了,主要是对namespace的处理,改完xml重启即可。
extends------->struts-default;来源于struts2的核心包!
action中的method属性,指明使用哪一个方法!
package中的abstract属性为true时,表示该包只能被继承,而没有action的实现!
对于action可以采用method匹配的方式!
<action name="reg_*" class="org.xiva.struts2.demo.bean.Register" method="{1}"> <result name="success">/WEB-INF/mess/message.jsp</result> <result name="error" type="redirect">/errors.jsp</result> </action>