Spring Boot Primer-using JSP

Source: Internet
Author: User

Steps to use:

1. Creating MAVEN Web Project projects

2. Add dependencies in the Pom.xml file

<project xmlns= "http://maven.apache.org/POM/4.0.0" xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"xsi:schemalocation= "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" > <modelversion>4.0.0</ Modelversion> <groupId>com.wyl</groupId> <artifactId>SpringbootJSP</artifactId> < packaging>war</packaging> <version>0.0.1-SNAPSHOT</version> <name>springbootjsp Maven Webapp</name> <url>http://maven.apache.org</url><properties> <java.version>1.7</java.version> </properties> <parent> <group    Id>org.springframework.boot</groupid> <artifactId>spring-boot-starter-parent</artifactId> <version>1.5.3.RELEASE</version> </parent> <dependencies> <dependency> <group      Id>junit</groupid> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> <dependency> <groupid>org.springframewor K.boot</groupid> <artifactId>spring-boot-starter-web</artifactId> </dependency><!--introducing Tomcat-dependent<dependency> <groupId>org.springframework.boot</groupId> <artifactid>spring-boot-sta Rter-tomcat</artifactid> <scope>provided</scope> </dependency><!--tomcat-jasper --<dependency> <groupId>org.apache.tomcat</groupId> <artifactid>tomcat-jasper</arti Factid> <version>9.0.0.M21</version> </dependency><!--introduction of servlet dependency --<dependency> <groupId>javax.servlet</groupId> <artifactid>javax.servlet-api</arti factid> <version>4.0.0-b07</version> <scope>provided</scope> &LT;/DEPENDENCY&G T<!--Introducing JSTL Tag Library --<dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> <version>1.2</version> </dependency><!--devtools plug-in, hot deployment--<dependency> <groupId>org.springframework.boot</groupId> <artifactid>spring-boot-dev Tools</artifactid> <optional>true</optional> <scope>true</scope> </dependency> </dependencies> <!--packaging Plugins--<build> <finalname&gt ; springbootjsp</finalname> <plugins> <plugin> <groupid>org.springframewo Rk.boot</groupid> <artifactId>spring-boot-maven-plugin</artifactId> <config Uration> <fork>true</fork><!--Thermal deployment takes effect must be added to </configuration> </plugin> </plugins> & Lt;/build></project>

3. Configure Application.properties Support JSP

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

4. Write test controller

@Controller  Public class Jspcontroller {    @RequestMapping ("indexjsp")    Public String index (map<string, Object> map) {        map.put ("Hello", "there is JSP");         return "index";  The map is/web-inf/jsp/index.jsp page    }}

5. Write JSP page

<%@ page language= "java" contenttype= "text/html; Charset=utf-8 "    pageencoding=" Utf-8 "%><! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd" >    helloJsp    ${ Hello}</body>

Spring Boot Primer-using 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.