Spring mvc-Exception Javax.servlet.ServletException:Could not resolve view with name ' xxx ' in servlets with Name ' Spring '

Source: Internet
Author: User

Recently, using the Spring MVC development Project, there was a problem:

Javax.servlet.ServletException:Could not resolve view with name ' OK ' on servlet with Name ' Spring 'At Org.springframework.web.servlet.DispatcherServlet.render (Dispatcherservlet.java:1162) at Org.springframework.web.servlet.DispatcherServlet.doDispatch (Dispatcherservlet.java:950) at Org.springframework.web.servlet.DispatcherServlet.doService (Dispatcherservlet.java:852) at Org.springframework.web.servlet.FrameworkServlet.processRequest (Frameworkservlet.java:882) at Org.springframework.web.servlet.FrameworkServlet.doDelete (Frameworkservlet.java:811) at Javax.servlet.http.HttpServlet.service (Httpservlet.java:643) at Javax.servlet.http.HttpServlet.service (Httpservlet.java:717) 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: 74) at Org.springframework.web.filter.OncePerRequestFilter.doFilter (Onceperrequestfilter.java:76) 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:76) 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:102) 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:859) at Org.apache.coyote.http11.http11protocol$http11connectionhandler.process (Http11protocol.java:30W) at Org.apache.tomcat.util.net.jioendpoint$worker.run (Jioendpoint.java:489) at Java.lang.Thread.run (Thread.java:619) ...

Cause of the exception: configured in the MVC configuration file:

<name= "Defaultcontenttype"  value= "text/html"/> 

and the URL (http://localhost:8080/SpringRestful/services/User/users?_method=delete)

The request does not have an extension, and the requested method does not have a @responsebody signature, and spring will assume that the result of your request is an HTML view, so the above exception is thrown. The workaround is any one of the following: 1.url request plus extension:
Http://localhost:8080/SpringRestful/services/User/users.json?_method=delete

2. Add @responsebody signature 3 on the requested method.
<name= "Defaultcontenttype"  value= "text/html"/> Change to <name= "Defaultcontenttype"  value= "Application/json"  />

Spring mvc-Exception Javax.servlet.ServletException:Could not resolve view with name ' xxx ' in servlets with Name ' Spring '

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.