Home > Java > javaTutorial > body text

How SpringBoot accesses jsp pages

WBOY
Release: 2023-05-28 12:22:06
forward
2081 people have browsed it

1. Add pom dependency

First add these two configurations on the basis of the original pom file

<!-- tomcat 的支持.--> 
   <dependency> 
     <groupid>org.springframework.boot</groupid> 
     <artifactid>spring-boot-starter-tomcat</artifactid> 
     <scope>provided</scope> 
   </dependency> 
 
   <dependency> 
     <groupid>org.apache.tomcat.embed</groupid> 
     <artifactid>tomcat-embed-jasper</artifactid> 
     <scope>provided</scope> 
   </dependency>
Copy after login

In fact, according to my own configuration, only configuring tomcat as follows can be successful. Run the project

2. Add relevant configurations in the springBoot configuration file

application.properties

#spring.mvc.view.prefix=/WEB-INF/jsp/ #spring.mvc.view.suffix=.jsp #application.message: Hello Phil 2.application.yml
[html] view plain copy
spring:     
  # HTTP ENCODING 
  http: 
    encoding.charset: UTF-8 
    encoding.enable: true 
    encoding.force: true 
   
  datasource: 
    validation-query: SELECT 1 
    test-on-borrow: true 
     
  mvc: 
    view: 
      prefix: /WEB-INF/jsp/ 
      suffix: .jsp
Copy after login

3. Create a jsp file under web-inf for all jsp folders Folder

How SpringBoot accesses jsp pages

4. Create a transfer method on the backend

@Controller public class F2FController { 
  @RequestMapping(value="/test") 
  public String testF2F() { 
    return "index"; 
     
  }
Copy after login

Debugging is successful, the picture runs as follows

How SpringBoot accesses jsp pages

The above is the detailed content of How SpringBoot accesses jsp pages. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!