spring 和structs2 整合开发404错误

zy835289010 2013-04-08 01:35:14
新手找了好就,不知道问题在哪,求个位大侠指点,下面上代码和图
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错误了,不知道哪里错了,求解
...全文
277 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
wangmengself 2013-04-08
  • 打赏
  • 举报
回复
最后因为什么?
zy835289010 2013-04-08
  • 打赏
  • 举报
回复
谢谢各位大神,问题已经解决,谢谢大家!
zy835289010 2013-04-08
  • 打赏
  • 举报
回复
引用 9 楼 feier00 的回复:
<context-param> <param-name>contextConfigLocation</param-name> <param-value> /WEB-INF/classes/applicationContext.xml </param-value> </context-param> ……
放到classes下了,其他3个配置文件是在src目录下见的建的
zy835289010 2013-04-08
  • 打赏
  • 举报
回复
引用 11 楼 wangmengself 的回复:
http://localhost:8080/struts2_spring/ 你这样访问报不报错?
报错的404
wangmengself 2013-04-08
  • 打赏
  • 举报
回复
http://localhost:8080/struts2_spring/ 你这样访问报不报错?
zy835289010 2013-04-08
  • 打赏
  • 举报
回复
引用 9 楼 feier00 的回复:
<context-param> <param-name>contextConfigLocation</param-name> <param-value> /WEB-INF/classes/applicationContext.xml </param-value> </context-param> ……
/WEB-INF/classes/org/applicationContext.xml ???
跳蚤图 2013-04-08
  • 打赏
  • 举报
回复
<context-param> <param-name>contextConfigLocation</param-name> <param-value> /WEB-INF/classes/applicationContext.xml </param-value> </context-param> applicationContext.xml的位置是/WEB-INF/classes/吗 你好像放在org包里了
zy835289010 2013-04-08
  • 打赏
  • 举报
回复
引用 7 楼 gzc145 的回复:
login.jsp呢?
<%@ 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>
gzc145 2013-04-08
  • 打赏
  • 举报
回复
login.jsp呢?
zy835289010 2013-04-08
  • 打赏
  • 举报
回复
来人呀,泪流满面啊,叫我怎么继续学下去,着么小小的问题都解决不了
zy835289010 2013-04-08
  • 打赏
  • 举报
回复
引用 4 楼 fangmingshijie 的回复:
改为 <action name="login" class="login">
还是404,呜呜
  • 打赏
  • 举报
回复
改为 <action name="login" class="login">
zy835289010 2013-04-08
  • 打赏
  • 举报
回复
哪位大侠 帮忙看看呀,弄了大半天了,纠结
zy835289010 2013-04-08
  • 打赏
  • 举报
回复
引用 1 楼 fangmingshijie 的回复:
应该是http://localhost:8080/struts2_spring/login.do或者.action吧
改了还是404错
  • 打赏
  • 举报
回复
应该是http://localhost:8080/struts2_spring/login.do或者.action吧

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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