最近使用spring mvc开发项目,遇到一个问题:
javax.servlet.ServletException: Could not resolve view with name 'ok' in 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:602)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:619)
引起该异常的原因:在mvc的配置文件中配置了:<property name="defaultContentType" value="text/html" />,而url(http://localhost:8080/SpringRestful/services/User/users?_method=delete)请求没有带扩展名,且请求的方法没有@ResponseBody签名,spring会认为你请求的结果是一个html的视图,所以才抛出了上面的异常。
解决方法如下任意一种:
1.url请求加上扩展名:http://localhost:8080/SpringRestful/services/User/users.json?_method=delete
2.请求的方法上加上@ResponseBody签名
3.<property name="defaultContentType" value="text/html" />改为<property name="defaultContentType" value="application/json" />
相关推荐
赠送jar包:javax.servlet-3.0.0.v201112011016.jar; 赠送原API文档:javax.servlet-3.0.0.v201112011016-javadoc.jar; 赠送源代码:javax.servlet-3.0.0.v201112011016-sources.jar; 赠送Maven依赖信息文件:...
implementation group: 'javax.servlet', name: 'javax.servlet-api', version: '***' Gradle (Short): implementation 'javax.servlet:javax.servlet-api:***' Gradle (Kotlin): implementation("javax.servlet:...
当你遇到“找不到javax.servlet.*”这样的错误时,通常是因为你的项目缺少了这个库,所以需要引入`javax.servlet.jar`来解决问题。 1. **Java Servlet简介** Java Servlet是Java平台上的一个标准,用于扩展服务器...
赠送jar包:javax.servlet-3.0.0.v201112011016.jar; 赠送原API文档:javax.servlet-3.0.0.v201112011016-javadoc.jar; 赠送源代码:javax.servlet-3.0.0.v201112011016-sources.jar; 赠送Maven依赖信息文件:...
implementation group: 'javax.servlet', name: 'javax.servlet-api', version: '***' Gradle (Short): implementation 'javax.servlet:javax.servlet-api:***' Gradle (Kotlin): implementation("javax.servlet:...
Files contained in javax.servlet.jar: META-INF/MANIFEST.MF javax/servlet/http/LocalStrings.properties javax.servlet.http.HttpSessionBindingListener.class javax.servlet....
赠送jar包:javax.servlet-api-4.0.1.jar; 赠送原API文档:javax.servlet-api-4.0.1-javadoc.jar; 赠送源代码:javax.servlet-api-4.0.1-sources.jar; 赠送Maven依赖信息文件:javax.servlet-api-4.0.1.pom; ...
implementation group: 'javax.servlet', name: 'javax.servlet-api', version: '***' Gradle (Short): implementation 'javax.servlet:javax.servlet-api:***' Gradle (Kotlin): implementation("javax.servlet:...
赠送jar包:javax.servlet-api-4.0.0.jar; 赠送原API文档:javax.servlet-api-4.0.0-javadoc.jar; 赠送源代码:javax.servlet-api-4.0.0-sources.jar; 赠送Maven依赖信息文件:javax.servlet-api-4.0.0.pom; ...
javax.servlet-api-3.1.0.jar,处理找不到servlet JAR的问题
在Java编程环境中,`javax.servlet.jar` 是一个非常重要的库,它包含了Servlet和JSP(JavaServer Pages)的核心API,是开发Web应用程序的基础组件。这个包由Java EE(Enterprise Edition)标准提供,允许开发者创建...
implementation group: 'javax.servlet', name: 'javax.servlet-api', version: '***' Gradle (Short): implementation 'javax.servlet:javax.servlet-api:***' Gradle (Kotlin): implementation("javax.servlet:...
在Java Web开发中,`javax.servlet.jar`和`javax.servlet.jsp.jar`是两个非常重要的库文件,它们分别提供了Servlet和JSP(JavaServer Pages)的核心API。这两个库是开发基于Java的Web应用程序不可或缺的部分,特别是...
下地址https://repo1.maven.org/maven2/javax/servlet/javax.servlet-api/3.1.0/ 各个版本都有 javax.servlet-api-3.1.0-sources.jar
javax.servlet JAR包,解决找不到 import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; jar包问题
implementation group: 'javax.servlet', name: 'javax.servlet-api', version: '***' Gradle (Short): implementation 'javax.servlet:javax.servlet-api:***' Gradle (Kotlin): implementation("javax.servlet:...
implementation group: 'javax.servlet', name: 'javax.servlet-api', version: '***' Gradle (Short): implementation 'javax.servlet:javax.servlet-api:***' Gradle (Kotlin): implementation("javax.servlet:...
赠送jar包:javax.servlet-api-4.0.0.jar; 赠送原API文档:javax.servlet-api-4.0.0-javadoc.jar; 赠送源代码:javax.servlet-api-4.0.0-sources.jar; 赠送Maven依赖信息文件:javax.servlet-api-4.0.0.pom; ...
implementation group: 'javax.servlet', name: 'javax.servlet-api', version: '***' Gradle (Short): implementation 'javax.servlet:javax.servlet-api:***' Gradle (Kotlin): implementation("javax.servlet:...