<!--Pom.xml -<Projectxmlns= "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/xsd/maven-4.0.0.xsd"> <modelversion>4.0.0</modelversion> <groupId>com.cn</groupId> <Artifactid>Test</Artifactid> <version>0.0.1-snapshot</version> <Packaging>Jar</Packaging> <name>Test</name> <Properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </Properties> <Parent> <groupId>Org.springframework.boot</groupId> <Artifactid>Spring-boot-starter-parent</Artifactid> <version>1.4.1.RELEASE</version> </Parent> <Dependencies> <Dependency> <groupId>Org.springframework.boot</groupId> <Artifactid>Spring-boot-starter-web</Artifactid> </Dependency> <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> <Dependency> <groupId>Junit</groupId> <Artifactid>Junit</Artifactid> <version>3.8.1</version> <Scope>Test</Scope> </Dependency> </Dependencies> <Build> <Plugins> <plugin> <groupId>Org.springframework.boot</groupId> <Artifactid>Spring-boot-maven-plugin</Artifactid> </plugin> </Plugins> </Build></Project>
#src/main/java/application.propertiesserver.port=8080 server.tomcat.uri-encoding= utf-8server.tomcat.access-log-enabled=trueserver.tomcat.basedir=./spring.mvc.view.prefix=/web-inf/jsp/ spring.mvc.view.suffix=.jsp
//Application.javaImportorg.springframework.boot.SpringApplication;Importorg.springframework.boot.autoconfigure.SpringBootApplication;ImportOrg.springframework.boot.web.support.SpringBootServletInitializer;/*** Hello world! **/@SpringBootApplication Public classApplicationextendsspringbootservletinitializer{ Public Static voidMain (string[] args)throwsException {springapplication.run (application.class, args); }}
ImportOrg.springframework.stereotype.Controller;ImportOrg.springframework.ui.Model;Importorg.springframework.web.bind.annotation.RequestMapping;Importorg.springframework.web.bind.annotation.ResponseBody; @Controller Public classIndexcontroller {@RequestMapping (value="/") //@ResponseBody PublicString Indexpage (model model) {Model.addattribute ("Say", "Hello World"); return"Index"; }}
<!--src/main/webapp/web-info/jsp/index.jsp--><%@ 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" > ${say}</ Body>
Spring boot 1.4.1 with JSP file sample