Get the App
SLTechnology News&Howtos  ›  Servers  › 

What to do if you use jsp in SpringBoot

Shulou Source: shulou.com Published: 2022-06-01 07:10:11 09月11日 Update

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!

Tags: Templates content files methods more problems configuration helpless for this do not use prefix reason can be passed suffix this skills framework articles experience cache Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS vpn Apple OPPO Reno Linux