Springboot (6): Web Development-Template engine JSP

Source: Internet
Author: User

First, the new project

650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M01/99/11/wKioL1lDhHmCc3_0AACchr2LV6o135.jpg "title=" 1497597109 (1). jpg "alt=" wkiol1ldhhmcc3_0aacchr2lv6o135.jpg "/>

650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M02/99/11/wKiom1lDhKvS9BgwAAE4CYkOeeA762.jpg "title=" 1497597156 (1). jpg "alt=" wkiom1ldhkvs9bgwaae4cykoeea762.jpg "/>

Note The new project does not have a webapp directory under Eclipse will automatically create the WebApp directory here we need to automatically create a WebApp directory and create Web-inf.

650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M00/99/11/wKiom1lDhzbBzsgLAABDTSJB-dM691.jpg "title=" 1497597815 (1). jpg "alt=" wkiom1ldhzbbzsglaabdtsjb-dm691.jpg "/>


Description of the Servletinitializer.java

1. This class is equivalent to our previous Web. xml

2, only more than 3.0 can otherwise need to add Web. xml

Second, the configuration

2.1. Pom.xml Configuration

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

2.2. Configuration prefix and suffix similar to SSPRINGMVC

spring.profiles.active=dev# configuration prefix and suffix spring.mvc.view.prefix=/web-inf/templates/spring.mvc.view.suffix=.jsp

Four, the code

Package Com.example.demo.controller;import Org.springframework.stereotype.controller;import Org.springframework.ui.model;import org.springframework.web.bind.annotation.requestmapping;/** * Created by Ly on 2017/6/16. */@Controller @requestmapping ("/demo1") public class Index {@RequestMapping ("/index") public String Index (model        ) throws Exception {Model.addattribute ("title", "Ceshi");    Return "index"; }}


Idea, there's a problem here. Use the eclipse structure as follows

650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M00/99/16/wKioL1lDqcOz9m74AABuiO841NQ335.jpg "title=" 1497606660 (1). jpg "alt=" wkiol1ldqcoz9m74aabuio841nq335.jpg "/>


index.jsp

<%@ taglib prefix= "Spring"  uri= "http// Www.springframework.org/tags "%><%@ taglib prefix=" C " uri=" http://java.sun.com/jsp/jstl/ Core "%><! Doctype html>

Visit http://localhost:8988/demo1/index

650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M02/99/16/wKioL1lDqWOxp75iAABILem-yOk280.jpg "title=" 1497606565 (1). jpg "alt=" wkiol1ldqwoxp75iaabilem-yok280.jpg "/>



This article is from "I Love Big gold" blog, please be sure to keep this source http://1754966750.blog.51cto.com/7455444/1939115

Springboot (6): Web Development-Template engine JSP

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.