HelloWorld.javapackage org.xmh.demo;import java.util.Date;
import java.text.DateFormat;
import com.opensymphony.xwork2.ActionSupport;public class HelloWorld extends ActionSupport {
private String message;
public String getMessage(){
return message;
}
public String execute(){
message="Hello World,Now is"+ DateFormat.getInstance().format(new Date());
return SUCCESS;
}}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>
<package name="tutorial" extends="struts-default">
<action name="HelloWorld" class="org.xmh.demo.HelloWorld">
<result>/HelloWorld.jsp</result>
</action>
</package>
</struts>
HelloWorld.jsp<%@ page contentType="text/html"; charset="UTF-8" %>
<%@ taglib prefix="s" uri="/struts-tags" %><html>
  <head>
    
    <title>Hello World!</title>  </head>
  
  <body>
    <h2>
     <s:property value="message"/>
    </h2>
   </body>
 </html>
Tomcat总是报404错误The requested resource (/HW/HelloWorld.action) is not available.
我现在找不出什么错误,是Tomcat还是代码问题,那位大大帮个忙啊

解决方案 »

  1.   

    配置文件:<result>/HelloWorld.jsp</result>
    改为<result name="success" type="redirect">/HelloWorld.jsp</result>
      

  2.   

    <struts>
        <package name="default" extends="struts-default">
            <action name="HelloWorld" class="org.xmh.demo.HelloWorld">
                <result>/HelloWorld.jsp</result>
            </action>
        </package>
    </struts>
    把包名改成default直接取请求。http://127.0.0.1:8080/工程名/HelloWorld.action
      

  3.   

    <package name="tutorial" extends="struts-default">
    这里name对不对啊
    <result>/HelloWorld.jsp</result>
    路径肯定不对
      

  4.   

    将HelloWorld.jsp直接放在WebRoot下。
    <result>HelloWorld.jsp</result>
      

  5.   

    2010-7-8 8:26:22 org.apache.catalina.core.StandardContext start
    严重: Error filterStart
    2010-7-8 8:26:22 org.apache.catalina.core.StandardContext start
    严重: Context [/HW] startup failed due to previous errors
    2010-7-8 8:26:24 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
    信息: Parsing configuration file [struts-default.xml]
    2010-7-8 8:26:25 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
    信息: Unable to locate configuration files of the name struts-plugin.xml, skipping
    2010-7-8 8:26:25 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
    信息: Parsing configuration file [struts-plugin.xml]
    2010-7-8 8:26:25 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
    信息: Parsing configuration file [struts.xml]
    2010-7-8 8:26:26 org.apache.coyote.http11.Http11BaseProtocol start
    信息: Starting Coyote HTTP/1.1 on http-8080
    2010-7-8 8:26:26 org.apache.jk.common.ChannelSocket init
    信息: JK: ajp13 listening on /0.0.0.0:8009
    2010-7-8 8:26:26 org.apache.jk.server.JkMain start
    信息: Jk running ID=0 time=0/47  config=null
    2010-7-8 8:26:26 org.apache.catalina.storeconfig.StoreLoader load
    信息: Find registry server-registry.xml at classpath resource
    2010-7-8 8:26:27 org.apache.catalina.startup.Catalina start
    信息: Server startup in 49235 ms
      

  6.   

    “HW”是什么玩艺?你deploy的war放在哪儿了?
      

  7.   

    你进入页面是用的 http://localhost:8080/HW/HelloWorld.action  这样是错误的
    web项目不能这么干
    HelloWorld.jsp放在webroot下后 http://localhost:8080/HelloWorld.action其他的配置没有写错
      

  8.   

    我把HelloWorld.jsp放在webroot下了。HW是工程名啊
      

  9.   

    把你访问请求的URL贴出来看看。。
      

  10.   

    不是找不到jsp的问题,而是找不到action的问题。
      

  11.   

    我访问的URL?那是干什么用的?
      

  12.   

    <package name="tutorial" extends="struts-default">
    改成
    <package name="tutorial" namespace="/" extends="struts-default">看看行不行。
      

  13.   

    出现这个
    2010-7-8 8:40:15 org.apache.catalina.core.StandardContext start
    严重: Error filterStart
    2010-7-8 8:40:15 org.apache.catalina.core.StandardContext start
    严重: Context [/HW] startup failed due to previous errors
      

  14.   

    报的错还是一样?你是怎么访问的?
    是http://服务器IP:端口号/HW/HelloWorld.action 吗?
      

  15.   

    struts应该是这个的配置文件有错,自己重新配置一下试试,把代码复制出来,重新试试吧!!
      

  16.   

    http://localhost:8080/HW/HelloWorld.action
      

  17.   

     没有在struts.xml的action 里面配置method属性,你不配它是找不到的,或者是用动态调用
      

  18.   

    <package name="tutorial" extends="struts-default" namespace="/HW">
    试试这个
    别的都别改
      

  19.   

    看看如下:
    commons-io-1.3.2.jar,commons-fileupload-1.2.1.jar这两个包加上去filter error 可以参考:
    http://www.blogjava.net/weikj/archive/2009/04/01/108079.html有可能是filter根本就没有作用,导致struts2根本就没配置好。
      

  20.   

    HW 是application content name , 不需要写在namespace里
      

  21.   

    楼主的tomcat版本是多少?
    有人说tomcat5.5以上的版本才支持struts2
    看这个帖子:http://www.0x54.org/p4nny/article.asp?id=156
      

  22.   

    web.xml中的filter 是怎么配置的。贴出来看看
      

  23.   

    恩,我这就给你发。机子刚才卡了。我重启了一下eclipse
      

  24.   

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

  25.   

    给你个例子,自己看看吧
    struts.xml放在src目录下<?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>
    <package name="com.struts2.action" extends="struts-default">
    <action name="helloword" class="com.struts2.action.HelloWorldAction">
    <result>jsp/success.jsp</result>
    </action>
    </package>
    </struts>
    web.xml放在webroot/WEB-INF下<?xml version="1.0" encoding="UTF-8"?>
    <web-app id="WebApp_ID" version="2.4"
    xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    <!-- action过滤器 -->
    <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>
    <!-- 字符集过滤器 
    <filter>
    <filter-name>charcode</filter-name>
    <filter-class>com.strtus2.filter.CharEncodeFilter</filter-class>
    <init-param>
    <param-name>encode</param-name>
    <param-value>utf-8</param-value>
    </init-param>
    </filter>
    <filter-mapping>
    <filter-name>charcode</filter-name>
    <url-pattern>*.action</url-pattern>
    </filter-mapping>
    -->
    <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>
    </web-app>首页index.jsp放在webroot目录下(日,没有jsp的)
    <%@ page language="java" contentType="text/html; charset=UTF-8"
        pageEncoding="UTF-8"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Insert title here</title>
    </head>
    <body>
    <a href="helloword.action">Click Me</a>
    </body>
    </html>
    success.jsp放在webroot/jsp下
    <%@ page language="java" contentType="text/html; charset=UTF-8"
        pageEncoding="UTF-8"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Insert title here</title>
    </head>
    <body>
    <%out.print("hello world"); %>
    </body>
    </html>这个应该不用说了吧package com.struts2.action;import com.opensymphony.xwork2.ActionSupport;public class HelloWorldAction extends ActionSupport{ @Override
    public String execute() throws Exception {

    return SUCCESS;
    }
    }
      

  26.   

    有错么?一个HelloWorld弄得我很无奈啊。。
      

  27.   

    HTTP Status 404 - There is no Action mapped for namespace / and action name HelloWorld.--------------------------------------------------------------------------------type Status reportmessage There is no Action mapped for namespace / and action name HelloWorld.description The requested resource (There is no Action mapped for namespace / and action name HelloWorld.) is not available.
    --------------------------------------------------------------------------------Apache Tomcat/5.5.26
      

  28.   

    你是做的是一个struts的列子啊!我以前做过,要我给你发一个给你!
      

  29.   

    好啊。你用邮箱发给我吧!![email protected]
      

  30.   

    There is no Action mapped for namespace / and action name HelloWorld.
    没有定义一个namespace 为/ 并且action为HelloWorld的Action配置成<package name="tutorial" namespace="/" extends="struts-default">
    应该就不会报这个错了。
      

  31.   

    少了action部分:
    <package name="tutorial" namespace="/" extends="struts-default">
            <action name="HelloWorld" class="org.xmh.demo.HelloWorld">
                <result>/HelloWorld.jsp</result>
            </action>
    </package>
      

  32.   

    应该是你的action配置出问题了,struts.xml中action配置的和访问的不正确!
      

  33.   

    现在报500错误了
    HTTP Status 500 - --------------------------------------------------------------------------------type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception org.apache.jasper.JasperException: /HelloWorld.jsp(1,1) Unterminated &lt;%@ page tag
    org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
    org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
    org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:132)
    org.apache.jasper.compiler.Parser.parseDirective(Parser.java:521)
    org.apache.jasper.compiler.Parser.parseElements(Parser.java:1557)
    org.apache.jasper.compiler.Parser.parse(Parser.java:127)
    org.apache.jasper.compiler.ParserController.doParse(ParserController.java:212)
    org.apache.jasper.compiler.ParserController.parse(ParserController.java:101)
    org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:156)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:296)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:277)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:265)
    org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:564)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:302)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:389)
    note The full stack trace of the root cause is available in the Apache Tomcat/5.5.26 logs.
    --------------------------------------------------------------------------------Apache Tomcat/5.5.26
      

  34.   

    你的struts2版本是多少?
    tomcat启动时还报如下错误吗?
    2010-7-8 8:26:22 org.apache.catalina.core.StandardContext start
    严重: Error filterStart
    2010-7-8 8:26:22 org.apache.catalina.core.StandardContext start
    严重: Context [/HW] startup failed due to previous errors (这行错误表名你项目根本就没发布起来)
      

  35.   

    问题是我发布了
    2010-7-8 9:29:20 org.apache.catalina.startup.HostConfig checkResources
    信息: Reloading context [/HW]
    2010-7-8 9:29:21 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
    信息: Parsing configuration file [struts-default.xml]
    2010-7-8 9:29:22 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
    信息: Unable to locate configuration files of the name struts-plugin.xml, skipping
    2010-7-8 9:29:22 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
    信息: Parsing configuration file [struts-plugin.xml]
    2010-7-8 9:29:22 com.opensymphony.xwork2.util.logging.commons.CommonsLogger info
    信息: Parsing configuration file [struts.xml]
      

  36.   

    你项目应该发布好了。只是jsp出错。
    你可以在该jsp上只显示helloworld 看看。其他的逻辑先去掉。
      

  37.   

    应该是界面上出错了!struts应该通了!
      

  38.   

    你的问题,描述的不是很清楚。
    你要实现 的是什么?
    通过URL  http://localhost:8080/HW/HelloWorld.action 
    来找到HW工程中的ACTION.吗?
    然后让其转到HelloWorld.jsp。是这样吗?struts.xml 中搞了半天,你写的是没什么问题,可是你的jsp页面,开头有问题。
    用这个<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib prefix="s" uri="/struts-tags" %>
    替换你的开头
      

  39.   

    还有一点,就是你的Struts.xml文件
    少写了ACTION的name=success改为 <package name="default" extends="struts-default">
            <action name="HelloWorld" class="org.xmh.demo.HelloWorld">
                <result name="success">/HelloWorld.jsp</result>
                       </action>
        </package>我已经在我这里成功了。你再试试看。
      

  40.   

    把jsp中 <%@ page contentType="text/html"; charset="UTF-8" %>
    改成 <%@ page contentType="text/html;charset=UTF-8" %>text/html;charset=UTF-8  应该都在contentType 中
      

  41.   

    顶分了,先看struts2的相关概念,或者直接下载现成的空白项目导入到开发工具中直接使用。
      

  42.   

    改了还是报500错误
    HTTP Status 500 - --------------------------------------------------------------------------------type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception org.apache.jasper.JasperException: /HelloWorld.jsp(1,1) Unterminated &lt;%@ page tag
    org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
    org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
    org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:132)
    org.apache.jasper.compiler.Parser.parseDirective(Parser.java:521)
    org.apache.jasper.compiler.Parser.parseElements(Parser.java:1557)
    org.apache.jasper.compiler.Parser.parse(Parser.java:127)
    org.apache.jasper.compiler.ParserController.doParse(ParserController.java:212)
    org.apache.jasper.compiler.ParserController.parse(ParserController.java:101)
    org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:156)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:296)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:277)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:265)
    org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:564)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:302)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:389)
    note The full stack trace of the root cause is available in the Apache Tomcat/5.5.26 logs.
    --------------------------------------------------------------------------------Apache Tomcat/5.5.26
      

  43.   

    http://blog.csdn.net/oyjqdlp364356378/archive/2010/07/06/5715745.aspx
      

  44.   

    路径缺少  namespace="/" 
    跳转名称缺少, name = "success"
      

  45.   

    package org.xmh.demo;import java.util.Date;
    import java.text.DateFormat;
    import com.opensymphony.xwork2.ActionSupport;public class HelloWorld extends ActionSupport {
        private String message;
        public String getMessage(){
            return message;
        }
        public String execute(){
            message="Hello World,Now is"+ DateFormat.getInstance().format(new Date());
            return SUCCESS;
        }}
      lz  你这里 明明是两个 方法,两个return 
    我个人 觉得 你<struts>
        <package name="tutorial" extends="struts-default">
            <action name="HelloWorld" class="org.xmh.demo.HelloWorld">
                <result>/HelloWorld.jsp</result>
            </action>
        </package>
    </struts>
    的  <result>/HelloWorld.jsp</result>
    应改为 <result name="SUCCESS">/HelloWorld.jsp</result>
      你看看 行不行?
      

  46.   

    建议LZ看看我给你弄得例子吧,写的还算详细,仔细的对比一下,不是什么大问题
    404错误无非就是.jsp文件找不到,action路径找不到等等
      

  47.   

    org.apache.jasper.JasperException: /HelloWorld.jsp(1,1) Unterminated &lt;%@ page tag
    是你的jsp的问题,你仔细看看在第一行第一列,好像是,看看你写错没有了,一般报500错误就是有无法解析的代码!
      

  48.   

    org.apache.jasper.JasperException: /HelloWorld.jsp(1,1) Unterminated &lt;%@ page tag是不是混入了其他的符号了,自己仔细检查哈
      

  49.   

    配置文件的success,你真的加了吗?
    你确定是按我写的写的吗?
    你的jsp文件开头,真的是在myeclipse中自已创建的?
    不是copy过来的?
      

  50.   

    你连你的Action提交都不对 而且action中获取message连set方法都没有 怎么获取