Springboot Integrating JSP templates

Source: Internet
Author: User

Springboot Integrating JSP templates

When using JSP in the Springboot framework, the page template uses JSP to introduce related dependencies in POM.XNL, otherwise it cannot be returned to the specified page in the controller

0, build Springboot framework one, add JSP related dependencies are as follows:
<!-- servlet 依赖. --><dependency>    <groupId>javax.servlet</groupId>    <artifactId>javax.servlet-api</artifactId>    <scope>provided</scope></dependency><!-- JSTL 依赖. --><dependency>    <groupId>javax.servlet</groupId>    <artifactId>jstl</artifactId></dependency><!-- tomcat 的支持. --><dependency>        <groupId>org.springframework.boot</groupId>        <artifactId>spring-boot-starter-tomcat</artifactId>        <scope>provided</scope></dependency><!-- -jasper依赖.(暂时不知道干啥的) --><dependency>    <groupId>org.apache.tomcat.embed</groupId>    <artifactId>tomcat-embed-jasper</artifactId>    <scope>provided</scope></dependency>
Second, the configuration file
spring.mvc.view.prefix=/WEB-INF/jspspring.mvc.view.suffix=.jsp
Third, controller
import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.GetMapping;import com.xujie.service.CountService;@Controllerpublic class CountController {        @Autowired    private CountService countService;        //跳转页面    @GetMapping("/index")    public String goIndex() {        return "index";    }}
Iv. writing the index.jsp page under/web-inf/jsp

Slightly

Springboot Integrating JSP templates

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.