新手找了好就,不知道问题在哪,求个位大侠指点,下面上代码和图
web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" 
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_3_0.xsd">
  <display-name></display-name>
  <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>
  <listener > 
<listener-class > 
org.springframework.web.context.ContextLoaderListener
</listener-class > 
</listener > 
<context-param>
<param-name>contextConfigLocation</param-name>
        <param-value>
            /WEB-INF/classes/applicationContext.xml
        </param-value>
</context-param>
  </web-app>structs.xml:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd">
<struts> <package name="default"  extends="struts-default">
        <action name="login" class="org.LoginAction">
            <result name="success">/login_success.jsp</result>
        </action>
    </package>
    </struts>applicationCintext.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"><bean id="login" class="org.LoginAction">
    </bean>
</beans>
LoginAction.java:package org;import com.opensymphony.xwork2.ActionSupport;public class LoginAction  extends ActionSupport{
private String username;
private String password;
public String execute(){
return ActionSupport.SUCCESS;
}
public String getUsername(){
return username; }
public void setUsername(String username){
this.username=username; }
public String getPassword(){
return password; }
public void setPassword(String password){
this.password=password; }}
还有一句
struts.objectFactory=spring
地址栏输入:http://localhost:8080/struts2_spring/login.jsp
就出现404错误了,不知道哪里错了,求解

解决方案 »

  1.   

    应该是http://localhost:8080/struts2_spring/login.do或者.action吧
      

  2.   

    改为 <action name="login" class="login">
      

  3.   

    <%@ page language="java" contentType="text/html; charset=utf-8"
        pageEncoding="utf-8"%>
        <html>
        <head><title>登录页面</title></head>
        <body>
        <form action="login.action"method="post">
        用户登录<br>
        姓名:<input type="text" name="username"/><br>
        密码:<input type="text" name="password"/><br>
        <input type="submit" value="登录"/>
        </form>
        </body>
        </html>
      

  4.   

    <context-param>
    <param-name>contextConfigLocation</param-name>
            <param-value>
                /WEB-INF/classes/applicationContext.xml
            </param-value>
    </context-param>
    applicationContext.xml的位置是/WEB-INF/classes/吗你好像放在org包里了
      

  5.   

     /WEB-INF/classes/org/applicationContext.xml   ???
      

  6.   

    http://localhost:8080/struts2_spring/ 你这样访问报不报错?
      

  7.   

    放到classes下了,其他3个配置文件是在src目录下见的建的