ajax 请求后台数据返回异常 及 提示404方法名不存在

Posted 长风傲天

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ajax 请求后台数据返回异常 及 提示404方法名不存在相关的知识,希望对你有一定的参考价值。

1、正常使用 Ajax 调取后台数据时,提示方法名不存在,Ajax前端正常,方法类bean注入正常,方法注解正常。但参数解析时出现异常。

@RequestMapping(value="/getProject")
	@ResponseBody
	public Map<String,Object> getProject(@RequestBody Map<String, Object> paraMap,HttpServletRequest request){
		Map<String, Object> map = new HashMap<String, Object>();
		String projectName = (String)paraMap.get("projectName");

  强转时出现了异常,未被捕获。具体为什么这个异常会影响request解析暂时还不晓得,有哪位大神知道的请留言解释一下,谢谢。

2、方法正常流转之后无法将数据直接返回页面。提示异常如下:

十月 19, 2016 2:36:47 下午 org.apache.catalina.core.StandardWrapperValve invoke
严重: Servlet.service() for servlet spring-mvc threw exception
javax.servlet.ServletException: File "/jsp/error.jsp" not found
	at org.apache.jasper.servlet.JspServlet.handleMissingResource(JspServlet.java:335)
	at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
	at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:551)
	at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:488)
	at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:229)
	at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:264)
	at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1208)
	at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:992)
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:939)
	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:920)
	at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:827)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:643)
	at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:801)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at com.zhaopin.common.filter.SessionFilter.doFilter(SessionFilter.java:111)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:606)
	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
	at java.lang.Thread.run(Thread.java:745)

  网上搜查相关资料说是重复提交了数据。检查前端发现,绑定点击事件的按钮前多加了个<a href=""> 。这个href=“” 影响了response跳转导致。

郁闷笔记下这些“事故”故事,缅怀(调试之痛苦)谨记(简单BUG浪费时间)之……………………

 

以上是关于ajax 请求后台数据返回异常 及 提示404方法名不存在的主要内容,如果未能解决你的问题,请参考以下文章

请求一个方法,后台能正常执行,前台报错404

ajax 后台java代码执行完毕 前端报404错误

页面一个post请求,后台执行将近5分钟后返回结果但是页面获取不到返回值,一直显示加载中,不是ajax请求

网页报404错误提示

2016-6-3Ajax异步复习

Spring MVC全局异常后返回JSON异常数据