设置struts.devMode为true无效

3213113 2014-07-25 11:01:25
在eclipse里,struts.xml文件如下:
<?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.devMode" value="true" />

<package name="default" namespace="/" extends="struts-default">

<action name="index_struts">
<result>
/index.jsp
</result>
</action>
</package>

<include file="example.xml"/>

<!-- Add packages here -->

</struts>


重启服务器后,修改<action name="index">为<action name="index">后打开网页报错如下:

Struts has detected an unhandled exception:

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

There is no Action mapped for namespace [/] and action name [index] associated with context path [/StrutsDemo]. - [unknown location]
com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:185)
org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:63)
org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:37)
com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:58)
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:552)
org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:409)
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1044)
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:313)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
java.lang.Thread.run(Thread.java:722)

You are seeing this page because development mode is enabled. Development mode, or devMode, enables extra debugging behaviors and reports to assist developers. To disable this mode, set:

struts.devMode=false
in your WEB-INF/classes/struts.properties file.


重启服务器能响应,为什么设置了 <constant name="struts.devMode" value="true" />不能自动响应?
...全文
989 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
hhhuua 2015-08-27
  • 打赏
  • 举报
回复
这个方法很有效 !!!太感谢了
sinat_30002549 2015-07-24
  • 打赏
  • 举报
回复
我也遇到了楼主一样的问题,我的struts版本2.3.16,我将 <constant name="struts.configuration.xml.reload" value="true"/>替换掉<constant name="struts.devMode" value="true" />,然后重新运行服务器,tomcat自动加载,访问时不会报错。 (备注:我的tomcat路径不存在空格)
baidu_20374639 2015-06-06
  • 打赏
  • 举报
回复
引用 12 楼 xiaoyaoyouzi163 的回复:
Stuts2的"struts.devMode"设置成true后,不起作用的解决办法 不用 <constant name="struts.devMode" value="true" /> 改成 <constant name="struts.configuration.xml.reload" value="true"/> 有人说是因为tomcat加了空格的问题,具体不清楚。 下面是4个开发模式常用配置的简介--- <!-- 开启使用开发模式,详细错误提示 --> <!-- <constant name="struts.devMode" value="true"/>--> <!-- 指定每次请求到达,重新加载资源文件 --> <!-- <constant name="struts.i18n.reload" value="true"/>--> <!-- 指定每次配置文件更改后,自动重新加载 --> <!-- <constant name="struts.configuration.xml.reload" value="true"/>--> <!-- 指定XSLT Result使用样式表缓存 --> <!-- <constant name="struts.xslt.nocache" value="true"/>--> 这样就好使了,网上copy的哈
果然还是这个有用,听别人说有可能也是因为Tomcat有空格的原因,真不知道具体原因,有知道原因的回复下,多多交流!
xiaoyaoyouzi163 2015-01-20
  • 打赏
  • 举报
回复
Stuts2的"struts.devMode"设置成true后,不起作用的解决办法 不用 <constant name="struts.devMode" value="true" /> 改成 <constant name="struts.configuration.xml.reload" value="true"/> 有人说是因为tomcat加了空格的问题,具体不清楚。 下面是4个开发模式常用配置的简介--- <!-- 开启使用开发模式,详细错误提示 --> <!-- <constant name="struts.devMode" value="true"/>--> <!-- 指定每次请求到达,重新加载资源文件 --> <!-- <constant name="struts.i18n.reload" value="true"/>--> <!-- 指定每次配置文件更改后,自动重新加载 --> <!-- <constant name="struts.configuration.xml.reload" value="true"/>--> <!-- 指定XSLT Result使用样式表缓存 --> <!-- <constant name="struts.xslt.nocache" value="true"/>--> 这样就好使了,网上copy的哈
kzzk12 2014-11-20
  • 打赏
  • 举报
回复
我的struts版本2.3.16, 出现和楼主同样的问题。 解决办法:在struts.xml中同时添加下面代码: <constant name="struts.enable.DynamicMethodInvocation" value="true" /> <constant name="struts.devMode" value="true" /> 结果:修改<action name="hello">为<action name="hellee">后,tomcat自动加载,访问时不会报错。
Brandy1224 2014-09-18
  • 打赏
  • 举报
回复
你的问题解决了吗?我也碰到了这个问题,是struts 2.3.16的,也是照着马士兵视频做的
3213113 2014-07-26
  • 打赏
  • 举报
回复
引用 5 楼 huxiweng 的回复:
你修改java代码或者jsp试试
还没有java文件,只有一个jsp文件,里面内容就是hello strut! 这还咋改
teemai 2014-07-26
  • 打赏
  • 举报
回复
你修改java代码或者jsp试试
3213113 2014-07-26
  • 打赏
  • 举报
回复
引用 2 楼 wlwlwlwl015 的回复:
每次在服务器启动的时候Struts2的ConfigurationManager对象才会去加载struts.xml文件~ 所有记住以后只要修改struts.xml的内容之后就要重启一下服务器~
但是加了这句话 <constant name="struts.devMode" value="true" /> 开发者模式为true,当修改了action name=""的值,浏览器相应的改变访问,应该是能访问到的啊,马士兵视频上这么做的没有问题,可是我的就是不响应。
3213113 2014-07-26
  • 打赏
  • 举报
回复
引用 1 楼 magi1201 的回复:
重启之后,加载的就是<constant name="struts.devMode" value="true" /> 重启前,加载的还是默认的产品模式,这时候,修改struts.xml,自然无法响应。
我重启之后,还是无法响应,可应该是响应的,这才是困扰了我很久的问题
小灯光环 2014-07-26
  • 打赏
  • 举报
回复
每次在服务器启动的时候Struts2的ConfigurationManager对象才会去加载struts.xml文件~ 所有记住以后只要修改struts.xml的内容之后就要重启一下服务器~
姜小白- 2014-07-26
  • 打赏
  • 举报
回复
重启之后,加载的就是<constant name="struts.devMode" value="true" /> 重启前,加载的还是默认的产品模式,这时候,修改struts.xml,自然无法响应。
3213113 2014-07-26
  • 打赏
  • 举报
回复
struts版本2.3.16

67,513

社区成员

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

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