首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

咨询几个struts2(eclipse)的初级有关问题

2013-09-17 
咨询几个struts2(eclipse)的初级问题1,struts2的配置文件struts.xml应该放在哪个位置?是放在javaresource

咨询几个struts2(eclipse)的初级问题
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 report

message There is no Action mapped for namespace [/] and action name [addUI] associated with context path [/Struts2].

description The requested resource is not available.
这是为何呢?



[解决办法]
放在resource下的src目录下,编译时eclipse自动放到classes下。

对于不能访问:
首先,你的项目名是Struts2 ?
正常来说肯定是:http://localhost:端口/项目名/namespace/action
也就是:http://localhost:8080/Struts2/test/addUI(如果你的项目名是Struts2)
如果不能访问,删除缓存文件,重新启动。
再试试,还不可以再继续问。

热点排行