IDEA开发Spring Boo(JSP跳转)

1.首先下载Spring-boot-cli,然后解压缩,将bin文件夹添加到环境变量

2.新建一个Spring Initializr工程,修改为自己想要的名字,默认next

3.在main文件夹下新建webapp,在webapp下新建WEB-INF

4.打开file->project structure->Module->添加web->path relative为你新建的webapp,发现文件夹上出现蓝点,表示成功

<!--添加对tomcat的支持-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>

<!--添加对jsp的支持-->
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<!--<scope>provided</scope>-->
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>

5.在WEB-INF文件夹新建JSP文件夹,放入JSP文件,代码如下

1 <%@ page contentType="text/html;charset=UTF-8"language="java" %>
2 <html>
3     <head>
4        <title>欢迎</title>
5     </head>
6     <body>
7          欢迎光临
8       </body>
9 </html>

6.在resources文件夹下的application.properties文件中添加如下代码

spring.mvc.view.prefix==/WEB-INF/JSP/
spring.mvc.view.suffix=.jsp

7.在java文件夹下新建一个包com.lemon.like,并在这个包下新建一个Controller文件,代码如下

package com.lemon.like;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class HelloController {
    @RequestMapping("wel")
    public String Wel(){
        return "Test";
    }
}

8.在TestApplication文件下,添加如下代码

@ComponentScan("com.lemon.like")

9.点击运行即可,在浏览器中打开localhost/wel

 

转载于:https://www.cnblogs.com/SakerLiu/p/9646537.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值