Spring Boot Project Add JSP support __JS

Source: Internet
Author: User

First step
Modify the Pom file and add the following

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactid>jstl</artifactid >
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat.embed</groupId>
            <artifactId>tomcat-embed-jasper</artifactId>
            <scope>provided</scope>
        < /dependency>

Second Step
Modify the properties file and add the following

spring.mvc.view.suffix=.jsp
spring.mvc.view.prefix=/web-inf/jsp/

Third Step
Adding source code

Package Com.yq.demo.controller;

Import Org.springframework.stereotype.Controller;
Import Org.springframework.ui.Model;
Import org.springframework.web.bind.annotation.RequestMapping;

@Controller public
class Jspcontroller {

    @RequestMapping ("/action5") public
    String Action05 (model model) {
        Model.addattribute ("message", "001");
        return "Action5";
    }

JSP file and its directory structure
action5.jsp

<%@ page language= "java" contenttype= "text/html; Charset=utf-8 "pageencoding=" UTF-8 "%> <%@ taglib prefix="
C "uri=" Http://java.sun.com/jsp/jstl/core "% >
<! DOCTYPE html>

Directory structure

Last validation

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.