为什么输入localhost:8080/success没有出现 成功! 啊??
网页不能访问
package spring02.Controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
/**
* ClassName: HelloControl
* Description:
*
* @Author hang
* @Create 2024/2/14 20:59
* @Version 1.0
*/
@Controller
public class HelloControl {
@ResponseBody
@RequestMapping("/hello")
public String hello(){
return "hello world";
}
@RequestMapping("/success")
public String success(){
return "success哈";
//classpath:/templates/success.html
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<h1>成功!</h1>
</body>
</html>
package spring02.Controller;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* ClassName: HelloControlTest
* Description:
*
* @Author hang
* @Create 2024/2/14 21:05
* @Version 1.0
*/
@SpringBootApplication
public class HelloControlTest {
public static void main(String[] args) {
SpringApplication.run(HelloControlTest.class,args);
}
}