刚接触struts 2,选择了2.1.6版本,郁闷的是发生了
tomcat日志里面没有任何错误或警告,但就是出现404错误
网上找了许多解决方法,试了很多,都不起作用:
0、tomcat 版本和路径:D:\apache-tomcat-6.0.20
1、配置文件编码要是最好是UTF-8——默认就是
2、导入的jar包——如下6个:
commons-fileupload-1.2.1.jar  
commons-logging-1.1.jar  
freeer-2.3.13.jar
ognl-2.6.11.jar
struts2-core-2.1.6.jar
xwork-2.1.2.jar
3、配置文件:
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">
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
  
<filter>
<filter-name>struts2</filter-name> 
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> 
</filter>
<filter-mapping>
<filter-name>struts2</filter-name> 
<url-pattern>/*</url-pattern> 
</filter-mapping>
</web-app>
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>    <constant name="struts.devMode" value="true" />    <package name="default" namespace="/" extends="struts-default">
        <action name="index" class="com.Action.LoginAction">
            <result name="success">/hello.jsp</result>
        </action>
    </package>
</struts>4、action:
package com.Action;import com.opensymphony.xwork2.*;public class LoginAction extends ActionSupport { public String execute(){
return SUCCESS;
}
}5、url:http://localhost:8080/ppdai1106/index

解决方案 »

  1.   

    http://localhost:8080/ppdai1106/index.action
      

  2.   

    有可能是hello.jsp没有找到,改为相对路径试验下
      

  3.   

    错误就是
    HTTP Status 404 - /ppdai1106/index.action--------------------------------------------------------------------------------type Status reportmessage /ppdai1106/index.actiondescription The requested resource (/ppdai1106/index.action) is not available.
    --------------------------------------------------------------------------------Apache Tomcat/6.0.20
      

  4.   

    <action name="index" class="com.Action.LoginAction">
    把Action的名字换一下试一试,我也遇到过类似的问题,目前也是一头雾水,但index可能会和已经存在也页面有冲突也有可能;
      

  5.   

    http://localhost:8080/ppdai1106/index.action看能不能找到,如果还以生404错误,在该页面上右键属性,看看URL。
      

  6.   

    ERROR: JDWP Unable to get JNI 1.2 environment, jvm->GetEnv() return code = -2
    JDWP exit error AGENT_ERROR_NO_JNI_ENV(183):  [../../../src/share/back/util.c:820]
    这是什么意思啊?
      

  7.   

    URL:http://localhost:8080/ppdai1106/index.action
    有问题吗?
      

  8.   

    ppdai1106工程确定是不是这个名字,到属性里看看 MyEclipse -》web下的名字
      

  9.   

    看下 class=“package.className”  class类是不是错了啊 !
      

  10.   

    我哭啊!!!真被你说中了我起的工程名称是ppdai1106,带属性里的名字竟然是ppdai-1106 
    这又是为什么呢?
      

  11.   

    我估计你的这个工程文件是复制ppdai-1106的吧,然后重命名的吧