What to do if you use jsp in SpringBoot
How to use jsp in SpringBoot? I believe many inexperienced people don't know what to do about it. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.
The default recommended template for the SpringBoot framework is: Thymeleaf is similar to the Freemarker .html template
Thymeleaf freemarker template syntax index.html = = > Welcome: ${name} = > static cache page
Integration of SpringBoot and jsp
Introduce dependency jsp, jstl
Jstl
Jstl
1.2
Org.apache.tomcat.embed
Tomcat-embed-jasper
Configure the attempt to resolve prefixes and suffixes, spring.mvc.view.prefix, spring.mvc.view.suffix in the application.yml file
Spring:
Profiles:
# Activate test configuration
Active: dev
Mvc:
View:
# Configure prefix
Prefix: /
# Configure suffix
Suffix: .jsp
Test by jumping to create a new UserController file
@ Controller
@ RequestMapping ("user")
Public class UserController {
@ RequestMapping ("findAll")
Public String findAll () {
System.out.println ("findAll")
Return "index"
}
}
If the above operations are finished, jsp is still not supported (the new version does not seem to need to configure this) Edit Configuration-- > Working directory-- > $MODULE_DIR$
For example, you can use http://localhost:8989/zq/user/findAll access to print out findAll, and then jump to index.jsp.
After reading the above, have you mastered the method of how to use jsp in SpringBoot? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!