为了证实这个奇怪的现象,特用两种软件进行测试实验:
实验一:IDE编译器:
首先我们先导入themleaf的依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
其次再编译配置文件
server.port=8001
spring.thymeleaf.cache=false
spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.suffix=.html
再其次编辑controller页面跳转
package com.Controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
@Controller
public class TestCon {
@GetMapping("/EMP")
public String get(){
return "a";
}
}
最终编写跳转页面a.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<a href="/EMP">click</a>
</body>
</html>
从上图可以看出页面已经成功跳转
那么我们接着进行实验二:
用eclipse实验:
同样四部曲:
首先我们先导入themleaf的依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
其次再编译配置文件
server.port=8001
spring.thymeleaf.cache=false
spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.suffix=.html
再其次编辑controller页面跳转
package com.Controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
@Controller
public class TestCon {
@GetMapping("/EMP")
public String get(){
return "a";
}
}
最终编写跳转页面a.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<a href="/EMP">click</a>
</body>
</html>
哈哈见证奇迹的时候到了
原来是这样啊:
仔细看图中的位置,系统自动生成的代码是不是感觉少了什么似的
自信点就是少东西了 么错就是一个 “/”
看它跳转了
擦!!!!!!!!!!!!!!!!!!!!!