<!-- newweekly.jsp在/webroot/jsp/weekly 开始的写法是这样,在加载页面时,会提示:
2011-7-19 16:24:07 com.opensymphony.xwork2.util.logging.jdk.JdkLogger warn 警告: No configuration found for the specified action: 'addWeekly' in namespace: '/jsp/weekly'. Form action defaulting to 'action' attribute's literal value.
-->
<s:form action="addWeekly" >
</s:form>
<!-- 根据查阅的资料 在后面加上namespace的属性 -->
<s:form action="addWeekly" namespace="/">
</s:form>
<!-- 这种写法一直不报错 --> <form action="addWeekly" > </form>
在struts.xml中只有一个package :
<package name="root" namespace="/" extends="struts-default"> <action name="login" class="com.jxwss.action.loginAction"> <result name="success">/jsp/frame/frame.jsp</result> <result name="input">/login.jsp</result> </action> <action name="newWeekly" class="com.jxwss.action.weeklyAction" method="newWeekly"> <result type="redirect">/jsp/weekly/newweekly.jsp</result> </action> <action name="addWeekly" class="com.jxwss.action.weeklyAction" method="addWeekly"> <result name="success">/jsp/weekly/newweekly-done.jsp</result> <result name="error">/jsp/weekly/newweekly-error.jsp</result> </action> <action name="listWeekly" class="com.jxwss.action.weeklyAction" method="listWeekly"> <result name="success">/jsp/weekly/listweekly.jsp</result> </action> </package>
根据错误信息,猜测如果使用了struts标签,在加载页面时会自动根据当前所在文件目录检测namespace(因为在错误信息里面看到报错是在/jsp/weekly这个namespace下找不到action)。只要在标签后面加上namespace就能放到指定的namespace下。