警告:No configuration found for the specified action: \'s

1.index.jsp页面form标签未指定namespace属性。

<!--index.jsp代码-->

<%@taglib prefix="s" uri="/struts-tags"%>
...
<s:form action="submit" method="post">
<s:textfield name="msg" label="叙述:"></s:textfield>
<s:submit value="保存" name="save" method="save"></s:submit>
<s:submit value="打印" name="print" method="print"></s:submit>
</s:form>

 

<!--struts.xml配置-->

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<include file="struts-default.xml" />
<package name="struts2" namespace="/my" extends="struts-default">
<action name="submit" class="pro.action.MoreSubmitAction">
<result name="success">/index.jsp</result>
</action>
</package>
</struts>

解决方法:在index.jsp的form标签加上namespace属性。跟struts.xml中namespace属性一致即可。

...

<s:form action="submit" method="post" namespace="/my">
<s:textfield name="msg" label="叙述:"></s:textfield>
<s:submit value="保存" name="save" method="save"></s:submit>
<s:submit value="打印" name="print" method="print"></s:submit>
</s:form>


2.struts.xml默认放在src目录下,如修改了配置目录。同样会出现警告:No configuration found for the specified action: 'submit' in namespace

解决方法:

a.把struts.xml文件放到src目录。

b.修改web.xml文件。在web.xml加上以下代码(例如struts.xml配置在WEWB-INF目录下):

<init-param>
<param-name>config</param-name>
<param-value>../struts.xml</param-value>
</init-param>

猜你喜欢

转载自chiangfai.iteye.com/blog/2210672