刚学struts2中出问题There is no Action mapped for namespace and action name

lingfeng892 2014-11-05 06:32:12
HTTP Status 404 - There is no Action mapped for namespace [/student/jibeninfo] and action name [danganziliao] associated with context path [/SSH].

“综合信息”那个是好的没有错误,但“档案资料”就出现了上面的404错误

xml文件:

jsp文件:
...全文
830 14 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
lingfeng892 2014-11-07
  • 打赏
  • 举报
回复
引用 12 楼 u012367513 的回复:
那就是tomcat缓存,如果猜得没错,你用的是myeclipse吧,原因是你myeclipse里面的项目和tomcat里面的项目是不一致的,你修改的,tomcat里面的没变,所以就不会有反应,你可以将项目重新部署一下(即remove后再add进去),试下可以不
解决了,我把开发工具换成MyEclipse后问题都解决了,但就是不知道为什么Eclipse会出现那么多莫名的问题
lingfeng892 2014-11-07
  • 打赏
  • 举报
回复
引用 12 楼 u012367513 的回复:
那就是tomcat缓存,如果猜得没错,你用的是myeclipse吧,原因是你myeclipse里面的项目和tomcat里面的项目是不一致的,你修改的,tomcat里面的没变,所以就不会有反应,你可以将项目重新部署一下(即remove后再add进去),试下可以不
还是不行,我用的Eclipse,我把servers中的SSH项目删除,又把tomcat目录webapps和work中的SSH删除,然后在Eclipse中重新部署SSH项目,但我的项目中现在是没有struts.xml文件的,结果一样可以访问/SSH/student/jibeninfo/zonghexinxi ,另外我还有个登录页面/user/userlogin也是在struts.xml中配置了也是可以访问的。 我配置的Action都是在其它的xml文件中(例如:struts-student.xml)然后用struts.xml文件包含进来的
  • 打赏
  • 举报
回复
那就是tomcat缓存,如果猜得没错,你用的是myeclipse吧,原因是你myeclipse里面的项目和tomcat里面的项目是不一致的,你修改的,tomcat里面的没变,所以就不会有反应,你可以将项目重新部署一下(即remove后再add进去),试下可以不
  • 打赏
  • 举报
回复
引用 4 楼 lingfeng892 的回复:
[quote=引用 2 楼 u012367513 的回复:] 试一下url前面去掉斜杠/ 如:student/jibeninfo/danganziliao
去掉两个都不行,就是不明白这点,为什么一个行一个不行[/quote] 首先,浏览器缓存有没有清理,这是最容易忽略的地方。 如果清除了,请看下面 HTTP Status 404 - There is no Action mapped for namespace [/student/jibeninfo] and action name [danganziliao] associated with context path [/SSH]. 从这里可以看出这是url映射错误,你可以在浏览器上按F12,查看里面报404错误的url到底是如何的,是不是localhost:8080/项目名/student/jibeninfo/danganziliao,如果不是,那就是url错误了,自己根据里面的情况调一下url就行了
lingfeng892 2014-11-06
  • 打赏
  • 举报
回复
引用 5 楼 u011952254 的回复:
你有没有映射你的action啊,这个提示的就是找不到你的action啊,你去检测下action呗,话说怎么不贴上你的action类呢,上图全面点撒。
看看6楼,谢谢了
lingfeng892 2014-11-06
  • 打赏
  • 举报
回复
Bean
<bean id="studentAction" class="com.xjgl.server.controller.action.student.StudentAction" scope="prototype"/>
Action
package com.xjgl.server.controller.action.student;

import javax.annotation.Resource;

import org.apache.log4j.Logger;

import com.opensymphony.xwork2.ActionContext;
import com.xjgl.server.entity.Usertb;
import com.xjgl.server.entity.child.StudentAll;
import com.xjgl.server.exception.MyException;
import com.xjgl.server.service.student.StudentService;

public class StudentAction {
	
	private static final Logger log = Logger.getLogger(StudentAction.class);

	@Resource
	private StudentService studentService;
	
	/**
	 * 查询一个学生的综合信息
	 * @return
	 */
	public String getZonghexinxi(){
		/*
		 *1、从session中取得保存的学号
		 *2、通过学号查询
		 *3、保存查询(失败时保存异常信息)
		 *4、无论成功失败都返回到综合信息页面
		 */
		StudentAll student = new StudentAll();
		
		Usertb user = (Usertb) ActionContext.getContext().getSession().get("user");
		
		try {
			student = studentService.findStudentInfoBySno(user.getUsernumber().trim());
			log.debug("查询出学号为" + student.getSno() + "的学生的信息");
			
			ActionContext.getContext().put("student", student);
			
			return "success";
		} catch (MyException e) {
			log.debug("查询失败");
			
			ActionContext.getContext().put("msg", e.getMessage());
			
			return "fail";
		}
	}
	
	/**
	 * 查询学生的档案资料
	 * @return
	 */
	public String getDanganziliao(){
		/*
		 *1、从session中取得保存的学号
		 *2、通过学号查询
		 *3、保存查询(失败时保存异常信息)
		 *4、无论成功失败都返回到档案资料页面
		 */
		StudentAll student = new StudentAll();
		
		Usertb user = (Usertb) ActionContext.getContext().getSession().get("user");
		
		try {
			student = studentService.findStudentInfoBySno(user.getUsernumber().trim());
			log.debug("查询出学号为" + student.getSno() + "的学生的档案资料");
			
			ActionContext.getContext().put("student", student);
			
			return "success";
		} catch (MyException e) {
			log.debug("查询失败");
			
			ActionContext.getContext().put("msg", e.getMessage());
			
			return "fail";
		}
	}
	
	
}
Silence-boby 2014-11-06
  • 打赏
  • 举报
回复
你有没有映射你的action啊,这个提示的就是找不到你的action啊,你去检测下action呗,话说怎么不贴上你的action类呢,上图全面点撒。
lingfeng892 2014-11-06
  • 打赏
  • 举报
回复
引用 2 楼 u012367513 的回复:
试一下url前面去掉斜杠/ 如:student/jibeninfo/danganziliao
去掉两个都不行,就是不明白这点,为什么一个行一个不行
lingfeng892 2014-11-06
  • 打赏
  • 举报
回复
引用 1 楼 sc6231565 的回复:
看看 src目录下 struts.xml 里 有没有引入 <include file="xx/l/ognl-struts.xml"/>
有这个文件,并且“综合信息那个是好的”,就是不明白这点,为什么一个行一个不行
lingfeng892 2014-11-06
  • 打赏
  • 举报
回复
引用 8 楼 u012367513 的回复:
[quote=引用 4 楼 lingfeng892 的回复:] [quote=引用 2 楼 u012367513 的回复:] 试一下url前面去掉斜杠/ 如:student/jibeninfo/danganziliao
去掉两个都不行,就是不明白这点,为什么一个行一个不行[/quote] 首先,浏览器缓存有没有清理,这是最容易忽略的地方。 如果清除了,请看下面 HTTP Status 404 - There is no Action mapped for namespace [/student/jibeninfo] and action name [danganziliao] associated with context path [/SSH]. 从这里可以看出这是url映射错误,你可以在浏览器上按F12,查看里面报404错误的url到底是如何的,是不是localhost:8080/项目名/student/jibeninfo/danganziliao,如果不是,那就是url错误了,自己根据里面的情况调一下url就行了[/quote] 我刚才测试的,我把struts.xml文件删除了后一样可以访问/SSH/student/jibeninfo/zonghexinxi ,可以进入“综合信息”页面,也能取到数据库的数据,不知道为啥
lingfeng892 2014-11-06
  • 打赏
  • 举报
回复
引用 8 楼 u012367513 的回复:
[quote=引用 4 楼 lingfeng892 的回复:]
[quote=引用 2 楼 u012367513 的回复:]
试一下url前面去掉斜杠/
如:student/jibeninfo/danganziliao
去掉两个都不行,就是不明白这点,为什么一个行一个不行[/quote]

首先,浏览器缓存有没有清理,这是最容易忽略的地方。

如果清除了,请看下面
HTTP Status 404 - There is no Action mapped for namespace [/student/jibeninfo] and action name [danganziliao] associated with context path [/SSH].
从这里可以看出这是url映射错误,你可以在浏览器上按F12,查看里面报404错误的url到底是如何的,是不是localhost:8080/项目名/student/jibeninfo/danganziliao,如果不是,那就是url错误了,自己根据里面的情况调一下url就行了[/quote]
lingfeng892 2014-11-06
  • 打赏
  • 举报
回复
引用 8 楼 u012367513 的回复:
[quote=引用 4 楼 lingfeng892 的回复:]
[quote=引用 2 楼 u012367513 的回复:]
试一下url前面去掉斜杠/
如:student/jibeninfo/danganziliao
去掉两个都不行,就是不明白这点,为什么一个行一个不行[/quote]

首先,浏览器缓存有没有清理,这是最容易忽略的地方。

如果清除了,请看下面
HTTP Status 404 - There is no Action mapped for namespace [/student/jibeninfo] and action name [danganziliao] associated with context path [/SSH].
从这里可以看出这是url映射错误,你可以在浏览器上按F12,查看里面报404错误的url到底是如何的,是不是localhost:8080/项目名/student/jibeninfo/danganziliao,如果不是,那就是url错误了,自己根据里面的情况调一下url就行了[/quote]
url是正确的:
  • 打赏
  • 举报
回复
试一下url前面去掉斜杠/ 如:student/jibeninfo/danganziliao
Magical茏 2014-11-05
  • 打赏
  • 举报
回复
看看 src目录下 struts.xml 里 有没有引入 <include file="xx/l/ognl-struts.xml"/>

67,550

社区成员

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

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