This article mainly introduces the implementation method of Spring boot jumping to jsp page. The editor thinks it is quite good. Now I will share it with you and give it as a reference. Let’s follow the editor to take a look.
I am learning Spring boot, and I have searched a lot about the implementation method of Spring boot jumping to jsp page. I will record it below, and friends who need to know can refer to it. Hope this article is helpful to you.
@Controller annotations
1. Configuration in the application.properties file
# 配置jsp文件的位置,默认位置为:src/main/webapp spring.mvc.view.prefix=/pages/ # 配置jsp文件的后缀 spring.mvc.view.suffix=.jsp
2. Configuration in the Controller file
import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; @Controller public class UserController { @RequestMapping(value = "/index",method = RequestMethod.GET) public String toIndex(){ return "index"; } }
3. Start the [main] method in the project App.Java
4. Access the url and access the jsp page: localhost:8080/index
@RestController annotation
1. Configuration in the application.properties file
# 配置jsp文件的位置,默认位置为:src/main/webapp spring.mvc.view.prefix=/pages/ # 配置jsp文件的后缀 spring.mvc.view.suffix=.jsp
2. Configuration in the RestController file
import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.RestController; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; @RestController public class UserController { @RequestMapping(value = "/index",method = RequestMethod.GET) public String toIndex(){ ModelAndView mv = new ModelAndView("index"); return mv; } }
3. Start the [main] method in the project App.java to start
4. Access the url and access the jsp page: localhost:8080/index
Note: application.properties The properties in spring.mvc.view.prefix and spring.mvc.view.prefix are different in the old version of spring-boot and in the new version:
Used in the old version:
spring.view.prefix=/pages/ spring.view.suffix=.jsp
Used in the new version:
spring.mvc.view.prefix=/pages/ spring.mvc.view.suffix=.jsp
[Related recommendations]
2. Java implementation Video tutorial on proportional thumbnails of pictures
The above is the detailed content of How to implement jsp page jump in java. For more information, please follow other related articles on the PHP Chinese website!

The article discusses using Maven and Gradle for Java project management, build automation, and dependency resolution, comparing their approaches and optimization strategies.

The article discusses creating and using custom Java libraries (JAR files) with proper versioning and dependency management, using tools like Maven and Gradle.

The article discusses implementing multi-level caching in Java using Caffeine and Guava Cache to enhance application performance. It covers setup, integration, and performance benefits, along with configuration and eviction policy management best pra

The article discusses using JPA for object-relational mapping with advanced features like caching and lazy loading. It covers setup, entity mapping, and best practices for optimizing performance while highlighting potential pitfalls.[159 characters]

Java's classloading involves loading, linking, and initializing classes using a hierarchical system with Bootstrap, Extension, and Application classloaders. The parent delegation model ensures core classes are loaded first, affecting custom class loa


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Atom editor mac version download
The most popular open source editor

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

Dreamweaver Mac version
Visual web development tools

Notepad++7.3.1
Easy-to-use and free code editor