struts 2.0(web工程Struts2_HelloWorld)初探报错

fengxiarong707 2007-07-29 04:39:12
报错:
HTTP Status 404 - /Struts2_HelloWorld/HelloWorld

--------------------------------------------------------------

type Status report

message /Struts2_HelloWorld/HelloWorld

description The requested resource (/Struts2_HelloWorld/HelloWorld) is not available.


---------------------------------------------------

环境:
jakarta-tomcat-5.5.7
jdk 1.5
struts-2.0.9
eclipse 3.2

web工程Struts2_HelloWorld描述:
stuts.xml配置:
<!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="tutorial" extends="struts-default">
<action name="HelloWorld" class="tutorial.HelloWorld">
<result>HelloWorld.jsp</result>
</action>
</package>
</struts>
自建有HelloWorld.java、SayHello.jsp、Helloworld.jsp三个文件。


启动tomcat时,有个警告:
信息: Parsing configuration file [struts.xml]
2007-7-29 16:29:43 org.apache.struts2.config.Settings getLocale
警告: Settings: Could not parse struts.locale setting, substituting default VM locale
2007-7-29 16:29:45 com.opensymphony.xwork2.util.ObjectTypeDeterminerFactory <clinit>


请问各位大侠,该如何解决?在此感谢!
...全文
1757 14 打赏 收藏 举报
写回复
14 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
shuyelove 2011-12-29
Struts Problem Report
Struts has detected an unhandled exception:

Messages: There is no Action mapped for namespace / and action name download.



--------------------------------------------------------------------------------

Stacktraces
There is no Action mapped for namespace / and action name download. - [unknown location]
com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:186)
org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:41)
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:494)
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:422)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:228)
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:216)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:634)
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:445)
java.lang.Thread.run(Thread.java:619)

这个怎么解决啊??
  • 打赏
  • 举报
回复
shuyelove 2011-12-29
怎么没有人理我啊????
  • 打赏
  • 举报
回复
龙翔飞雪 2008-01-17
我也碰到这个问题, 找了很多帖子, 大多回答差不多...
关键错误是:
Unable to load bean: type:com.opensymphony.xwork2.ObjectFactory class:org.apache.struts2.spring.StrutsSpringObjectFactory

后来我发现:
1. 首先不要有多余的jar, commons-logging-1.1.jar freemarker-2.3.8.jar ognl-2.6.11.jar struts2-core-2.0.6.jar xwork-2.0.1.jar是struts2必须的 (小版本号不同无所谓)
2. 直接在MyEclipse里运行tomcat, 好像每次必定碰到这个错误 (这个错误是由于struts-plugin.xml引起的), export成.war, 放到tomcat里, 就成功了.
(难道MyEclipse里面做了什么多余的东东?? 不明, 我用的是MyEclipse6, 被这个问题困惑了很久)
  • 打赏
  • 举报
回复
fengxiarong707 2007-08-11
开始工程是在eclipse下用web --> dynamic web project 建立的,导入相应的包,这样子运行后就报404的错;
现在我用 java -->Tomcat project 创建工程,就没有问题了,启动时虽也有警告。

楼上兄弟如果还有问题,把错误信息贴出来看看。
  • 打赏
  • 举报
回复
masterlife21 2007-08-08
问题你怎么解决的,我遇到同样的问题,警告是没有了。
但是找不到map....
  • 打赏
  • 举报
回复
pengxuan 2007-08-04
我也遇到这种问题,是由于struts.xml发布位置引起的

在myeclipse开发环境中,struts.xml的位置应该在src目录下,不应该在WEB-INF目录下!
  • 打赏
  • 举报
回复
fengxiarong707 2007-08-04
楼上兄弟不要导入-plungin的包,这个应该就ok了。
明晚结贴。
  • 打赏
  • 举报
回复
huangtut 2007-08-02
我也是报错,我用的是eclipse3.2.1,引入了struts2.0.9 lib 下的包,刚建了index.html,可惜启动的时候报错
Unable to load bean: type:com.opensymphony.xwork2.ObjectFactory class:org.apache.struts2.spring.StrutsSpringObjectFactory - bean - jar:file:/F:/tomcat-5.5.23/webapps/st2/WEB-INF/lib/struts2-spring-plugin-2.0.9.jar!/struts-plugin.xml:8:132
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:208)
at org.apache.struts2.config.StrutsXmlConfigurationProvider.register(StrutsXmlConfigurationProvider.java:101)
at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reload(DefaultConfiguration.java:131)
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:52)
at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:395)
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:452)
at org.apache.struts2.dispatcher.FilterDispatcher.init(FilterDispatcher.java:201)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:221)
at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:302)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:78)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3635)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4222)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:760)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:740)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:544)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:825)
at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:714)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:490)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:120)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1022)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:736)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:448)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:700)
at org.apache.catalina.startup.Catalina.start(Catalina.java:552)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:295)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433)
Caused by: java.lang.NoClassDefFoundError: org/springframework/context/ApplicationContextAware
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1847)
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:873)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1326)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1205)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1847)
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:873)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1326)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1205)
at com.opensymphony.xwork2.util.ClassLoaderUtil.loadClass(ClassLoaderUtil.java:139)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:180)
... 33 more


  • 打赏
  • 举报
回复
fengxiarong707 2007-07-31
工程是在eclipse下用web --> dynamic web project 建立的,导入相应的包,这样子运行后就报404的错;
现在我用 java -->Tomcat project 创建工程,就没有问题了,启动时虽也有警告。

仍希望有大侠能给出why。
  • 打赏
  • 举报
回复
fengxiarong707 2007-07-30
我就照搬网络上一篇struts 2.0的初探,咋就不通过。
web.xml:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>Struts 2.0 Hello World</display-name>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app>

HelloWorld.java:

package tutorial;
import com.opensymphony.xwork2.ActionSupport;
public class HelloWorld extends ActionSupport {
private String name;

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String execute() {
name = "Hello, " + name + "!";
return SUCCESS;
}

}
  • 打赏
  • 举报
回复
Cappuccino_mhc 2007-07-30
我也在求2.0
  • 打赏
  • 举报
回复
wangzhouyu 2007-07-30
Struts2_HelloWorld/HelloWorld,HelloWorld是什么,是一个action么?看看你的web.xml配置的filter是对那些名进行过滤。
  • 打赏
  • 举报
回复
fengxiarong707 2007-07-30
直接在地址栏位中输入:http://localhost:8080/Struts2_HelloWorld/HelloWorld.action

报错:
There is no Action mapped for namespace / and action name HelloWorld. - [unknown location]
com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:186)
org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:41)
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:494)
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:419)

1.create struts.properties 也没用;
2.在struts.xml中加入:<constant name="struts.locale" value="en_US" />也没有用。

启动时有两次警告:
Settings: Could not parse struts.locale setting, substituting default VM locale
  • 打赏
  • 举报
回复
sureyor 2007-07-30
try try:
creating a /WEB-INF/classes/struts.properties file with struts.locale=en_GB

  • 打赏
  • 举报
回复
相关推荐
发帖
Java EE
加入

6.7w+

社区成员

J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
申请成为版主
帖子事件
创建了帖子
2007-07-29 04:39
社区公告
暂无公告