1,struts2的配置文件struts.xml应该放在哪个位置?是放在javaresource下的src目录下还是WEB-INF的classes下。2,
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd"><struts>
<package name="dzr" namespace="/test" extends="struts-default">
<action name="helloworld" class="cn.dzr.action.HelloWorldAction" method="execute">
<result name="success">/WEB-INF/page/hello.jsp</result>
</action>
<action name="addUI">
<result>/WEB-INF/page/employeradd.jsp</result>
</action>
</package>
</struts>
这段代码,我访问addUI的时候,
http://localhost:8080/Struts2/addUI
http://localhost:8080/Struts2/test/addUI
以如上两个路径,浏览器均提示如下错误:type Status reportmessage There is no Action mapped for namespace [/] and action name [addUI] associated with context path [/Struts2].description The requested resource is not available.
这是为何呢?
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd"><struts>
<package name="dzr" namespace="/test" extends="struts-default">
<action name="helloworld" class="cn.dzr.action.HelloWorldAction" method="execute">
<result name="success">/WEB-INF/page/hello.jsp</result>
</action>
<action name="addUI">
<result>/WEB-INF/page/employeradd.jsp</result>
</action>
</package>
</struts>
这段代码,我访问addUI的时候,
http://localhost:8080/Struts2/addUI
http://localhost:8080/Struts2/test/addUI
以如上两个路径,浏览器均提示如下错误:type Status reportmessage There is no Action mapped for namespace [/] and action name [addUI] associated with context path [/Struts2].description The requested resource is not available.
这是为何呢?
首先,你的项目名是Struts2 ?
正常来说肯定是:http://localhost:端口/项目名/namespace/action
也就是:http://localhost:8080/Struts2/test/addUI(如果你的项目名是Struts2)
如果不能访问,删除缓存文件,重新启动。
再试试,还不可以再继续问。