Struts2使用开发模式遇到问题。本人刚学,希望各位能帮忙解决一下。感谢。

chen木木 2014-06-01 05:22:04
<constant name="struts.devMode" value="true" />
<package name="default" namespace="/" extends="struts-default">

<action name="hell">
<result>
/Hello.jsp
</result>
</action>
</package>


刚学Struts2 遇到个问题。
使用 <constant name="struts.devMode" value="true" /> 开发模式
然后在重新启动tomacat之后,把 struts.xml中的 action改了名字之后, 打开页面 出现了 这个异常,怎么解决。
Struts Problem Report
Struts has detected an unhandled exception:

Messages: There is no Action mapped for namespace [/] and action name [hello] associated with context path [/Struts2_0100_introduction].

如果我又把action换回之前的名字,页面还是能正常显示。
...全文
234 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
shpery 2014-06-20
  • 打赏
  • 举报
回复
action名称要一致 页面和配置文件里的 绑定下类 最后把项目REMOVE掉 重新部署一下
悍M 2014-06-20
  • 打赏
  • 举报
回复
参考下这个吧 <?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> <constant name="struts.custom.i18n.resources" value="message"></constant> <package name="default" extends="struts-default"> <interceptors> <!-- 声明拦截器 --> <interceptor name="privilege" class="cn.itcast.user.web.interceptor.privilegeInterceptor"> <param name="excludeMethods">login</param> <param name="includeMethods">add,edit,del,findAll,findById,download,display</param> </interceptor> <interceptor name="myexception" class="cn.itcast.user.web.interceptor.ExceptionInterceptor"></interceptor> <interceptor-stack name="mystack"> <interceptor-ref name="myexception"></interceptor-ref> <interceptor-ref name="privilege"></interceptor-ref> <interceptor-ref name="defaultStack"></interceptor-ref> </interceptor-stack> </interceptors> <global-results> <result name="login">/login/login.jsp</result> <result name="error">/error.jsp</result> </global-results> <action name="user_*" class="cn.itcast.user.web.action.UserAction" method="{1}"> <result name="login_success">/login/home.jsp</result> <result name="add_success" type="redirectAction">user_findAll</result> <result name="login_input">/login/login.jsp</result> <result name="add_input">/user/add.jsp</result> <result name="input">/input.jsp</result> <result name="findAll_success">/user/list.jsp</result> <result name="findById_success">/user/view.jsp</result> <result name="del_success" type="redirectAction">user_findAll</result> <result name="download_success" type="stream"> <param name="contentType">${contentType}</param> <param name="contentDisposition">attachment;filename=${downloadfile}</param> <param name="inputStream">${inputStream}</param> </result> <result name="display_success">/user/edit.jsp</result> <result name="edit_success" type="redirectAction">user_findAll</result> <interceptor-ref name="mystack" /> </action> </package> </struts>
jiabiaoli 2014-06-19
  • 打赏
  • 举报
回复
namespace="/" <action name="hell"> 而你访问的是/hello的问题..
懒懒程序员 2014-06-02
  • 打赏
  • 举报
回复
可以为/,应该是class少配置了。
Iver_99 2014-06-02
  • 打赏
  • 举报
回复
目测表单中的action少了/,因为你package中命名空间为/
姜小白- 2014-06-02
  • 打赏
  • 举报
回复
改名字的时候,java类和配置文件同时修改,保证名字一致。 tomcat的热部署,struts的开发模式,我觉得都不要太相信它们,每次修改部署后还是老老实实重启一下tomcat吧,这样保险。
orzxxx01 2014-06-02
  • 打赏
  • 举报
回复
这个开发模式没什么关系吧 action的名字本来就必须和配置文件中的一致,不然程序找不到
Elvins 2014-06-02
  • 打赏
  • 举报
回复
根据你提供的ACTION标签的写法就有点问题吧。我记得是要有个class的吧。 如:<action name="login" class="com.user.LoginAction"> 要绑定到实际的类的吧。
zy_think123 2014-06-02
  • 打赏
  • 举报
回复
这个和开发模式是没有关系的,开发模式只是说你可以使用<s:debug></s:debug>标签来查看数据 你造成异常的原因是Action标签中需要加入class=""属性
lee_wentao 2014-06-01
  • 打赏
  • 举报
回复
struts配置的action名字要和表单里action一样啊。还有表单里面参数名字和Action类里面的的参数名也要一样。你改了另一边没改怎么会显示。

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧