Spring Boot Did not find handler method for [/WEB-INF/views/index.html]
2017-03-29 19:04
639 查看
Spring Boot Did not find handler method for [/WEB-INF/views/index.html]
使用spring boot进行开发的时候,把静态的html页面放到了web-inf之下,然后添加了如下的配置spring.mvc.view.prefix=/WEB-INF/views/ spring.view.suffix=.html
程序启动访问
index.html页面,一直都是404,控制台打印
Did not find handler method for [/WEB-INF/views/index.html]。
就是说没有配置这个链接,但是这个文件确实是存在的,一时有点懵。
百度说这个错误的原因是因为没有对应的解析html的解析器,可以参考http://stackoverflow.com/questions/13616821/make-html-default-view-spring-mvc
只要添加了对应的解析器就可以了,我使用了thymeleaf模板去解析html。
需要在pom.xml中添加对应的jar包
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency>
之后在application.properties中添加
#配置解析html spring.thymeleaf.prefix=/WEB-INF/views/ spring.thymeleaf.suffix=.html spring.thymeleaf.mode=HTML5 spring.thymeleaf.encoding=UTF-8 spring.thymeleaf.content-type=text/html #开发时设置为false,否则看不到实时的页面 spring.thymeleaf.cache=false
这样再次访问就ok了,但是thymeleaf对html页面格式比较严格,每个标签都必须有对应的结束标签,否则就会报错
相关文章推荐
- Spring MVC spring Did not find handler method for 页面显示404问题
- springmvc restful Did not find handler method for
- spring 笔记2:Spring MVC : Did not find handler method for 问题的解决
- Did not find handler method for springMVC资源文件扫描不到---关于spring的那些坑
- Did not find handler method for[/XXX.html]
- 使用ControllerAdvice注意事项,Ambiguous @ExceptionHandler method mapped for [class org.springframework.web.bind.MethodArgumentNotValidException]
- Can not find the tag library descriptor for "/WEB-INF/struts-html.tld"报错
- Freemarker TemplateLoader.findTemplateSource("WEB-INF/template/index.html"): Not found错误原因
- 记一次did not find handler method问题
- No mapping found for HTTP request with URI [/spring/WEB-INF/page/index.jsp] in DispatcherServlet with name &#39;spring&#39;
- Java Web 学习笔记 The origin server did not find a current representation for the target resource or is
- No mapping found for HTTP request with URI [/spring/WEB-INF/page/index.jsp] in DispatcherServlet with name 'spring'
- 异常:javax.xml.ws.WebServiceException: Could not find wsdl:binding operation info for web method sayHi
- Could not find wsdl:binding operation info for web method sayHi
- IDEA的javaweb项目的 The origin server did not find a current representation for the target resource
- org.springframework.web.servlet.PageNotFound noHandlerFound 警告: No mapping found for HTTP request w
- Archive for required library: ‘WebContent/WEB-INF/lib/xxx.jar cannot be read or is not Zip file
- ORA-12520: TNS:listener could not find available handler for requested type of server
- Looks like the Spring listener was not configured for your web app!
- Setting property 'source' to 'org.eclipse.jst.jee.server:webProject' did not find a matching propert