*********来看看:Struts2的HelloWorld 怎么都不能运行,高手帮忙 ***************

foyuan 2007-10-26 09:56:29
写了一个Struts2的HelloWorld 怎么都不能运行,高手帮忙看看?多谢。
文件的结构:

---Hello
--index.html
--WEB-INF
--web.xml
--lib(struts2所有的jar)
--classes
--struts.xml


index.html里面就一个HelloWorld,
struts.xml内容:

<?xml version="1.0" encoding="UTF-8" ?>
<!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"/>
</struts>


web.xml内容如下:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>Hello</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>


运行 localhost:8000/Hello/index.html
或者运行 运行 localhost:8000/Hello/
都说 HTTP Status 404 - /Hello/index.html 删掉web.xml就正常,请高手看看哪里出错了。

多谢多谢!!
...全文
342 14 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
foyuan 2007-10-29
  • 打赏
  • 举报
回复
<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>

我发现把web.xml中的filter删除掉就可以了 ,不知道为什么?
wipe_tear 2007-10-27
  • 打赏
  • 举报
回复
struts-xml 配置文件对吗?
好像有问题哦,看这个样子很可能是类似path=/xx.do这样的东西没有配置好
wellon 2007-10-27
  • 打赏
  • 举报
回复
宝贝这是webwork
Kokonol 2007-10-27
  • 打赏
  • 举报
回复
struts-default.xml
在哪呢?
john_yong 2007-10-27
  • 打赏
  • 举报
回复
这里面要FILTER干什么?你的页面中都没有的呀!
好乱呀!不怎么理解!
一般里面还有SERVLET的配置吧!
foyuan 2007-10-27
  • 打赏
  • 举报
回复
谁能发一个Struts2的helloworld呢 谢谢
foyuan 2007-10-26
  • 打赏
  • 举报
回复
因为就没有写什么Action 直接请求了一个 index.html

所以没有社么可以编译的啊!
ii322 2007-10-26
  • 打赏
  • 举报
回复
// C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\HelloServlet does not exist or is not a readable directory
=========================================
重新编译 HelloServlet 未找到
HelloServlet没有配置到webapps下面啦

编译完后 看看webapps下面有没有HelloServlet这个文件夹

估计是对应错了 存到别的地方去了 仔细检查一下
foyuan 2007-10-26
  • 打赏
  • 举报
回复
查看了 log 发现有这样的错误,我请求的是index.html
帮忙看一下 谢谢
SEVERE: Error starting static Resources
java.lang.IllegalArgumentException: Document base C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\HelloServlet does not exist or is not a readable directory
at org.apache.naming.resources.FileDirContext.setDocBase(FileDirContext.java:141)
at org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java:3944)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4113)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:626)
at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:553)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:488)
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:117)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:566)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Oct 26, 2007 10:24:48 AM org.apache.catalina.core.StandardContext start
SEVERE: Error in resourceStart()
Oct 26, 2007 10:24:48 AM org.apache.catalina.core.StandardContext start
SEVERE: Error getConfigured
Oct 26, 2007 10:24:48 AM org.apache.catalina.core.StandardContext start
SEVERE: Context [/HelloServlet] startup failed due to previous errors
Oct 26, 2007 10:24:48 AM org.apache.catalina.core.StandardContext stop
INFO: Container org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/HelloServlet] has not been started
mx1029 2007-10-26
  • 打赏
  • 举报
回复
struts.xml 放到WEB-INF目录下?
ssfboy_2000 2007-10-26
  • 打赏
  • 举报
回复
报错首先看日志文件,不然除非你把文件都传上来,要不很难知道你错在什么地方

出现404的原因有很多,原因是找不到文件,当项目没有启动起来的时候,那么项目下的所有的文件都是不可见的
按照你的情况,出现的可能就是项目没有启动起来,检查filter类在启动的时候是否报出异常

还有html是不经过应用服务器解析的
ii322 2007-10-26
  • 打赏
  • 举报
回复
啊。。。。晕倒

没见到过 不清楚 。。。。:)
foyuan 2007-10-26
  • 打赏
  • 举报
回复
怎么编译呢?
我用Eclipse 就没有编译选项

只有导出 导出war文件
ii322 2007-10-26
  • 打赏
  • 举报
回复
//因为就没有写什么Action 直接请求了一个 index.html

//所以没有社么可以编译的啊!
======================================================

你管它有什么可编译的

你编译就是啦

刚才那个错误就是说 HelloServlet不存在或者怎么样

那你就把HelloServlet放到那个文件下面 看看它还有什么错

时刻关注中。。。。。。。

81,122

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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