1.建立一个web项目
2.添加pom.xml的依赖
<dependency> <groupId>org.apache.tomcat.embed</groupId> <artifactId>tomcat-embed-jasper</artifactId> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> <version>1.2</version> </dependency>
3.添加配置application.properties
spring.mvc.view.prefix=/jsp/ spring.mvc.view.suffix=.jsp
4.控制器
@Controller public class TestController { @RequestMapping(value = "/index",method = RequestMethod.GET) public String hello(){ return "index"; } }
5.然后在建一个index.jsp
6.在浏览器输入http://localhost:8080/index 运行