@RestController("/user/auth")
@RestController的小括号当中填写的内容,相当于@Service("")当中填写的内容,即spring bean的名称;
The value may indicate a suggestion for a logical component name,
to be turned into a Spring bean in case of an autodetected component.
该值可能表示一个逻辑组件名称的建议,在自动检测到组件的情况下,将其转换为Spring bean。
所以如果是要填写路径的话,还是需要使用@RequestMapping("/user/gateway")才是正确的;
否则将让人产生误解;

而事实上应该的写法是
@RestController()
@RequestMapping("/user/auth")
@Api(value = "用户认证控制层,", tags = {"用户认证控制层 —— UserAuthController"}, description = "用户认证控制层")
@Slf4j
public class UserAuthController {
才正确

本文详细解析了@RestController与@RequestMapping在Spring MVC中的作用。@RestController注解用于标记控制器类,其等价于@Controller+@ResponseBody,而@RequestMapping则用于指定请求映射。正确的使用方式是结合@RestController和@RequestMapping来定义控制器的URL路径。示例代码展示了最佳实践。
2968

被折叠的 条评论
为什么被折叠?



