1.可以加在类上 用于模块
2.可以加在方法上 用于路径
package com.cj.mvc.controller; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; @Controller @RequestMapping("test") public class TestController { @RequestMapping("test1") public String test1(){ return "test1"; } }
<!DOCTYPE html> <html lang="en" xmlns:th="http://www.thymeleaf.org"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <h1>首页</h1> <a th:href="@{/test/test1}">测试1</a> </body> </html>
标签:test1,RequestMapping,springMVC,springframework,Controller,import,public From: https://www.cnblogs.com/cciscc/p/16626107.html