@Controller返回json使用@ResponseBody
@Controller 返回string 默认是返回view的名字,想要直接返回json则需要@ResponseBody
@GetMapping("/map")
@ResponseBody
public java.util.Map<String,String> test(){
java.util.Map<String,String> map = new HashMap<>();
map.put("hello","hello");
return map;
}
@RestController返回页面
@RestController默认返回json,想要返回页面则需要方法体返回ModelAndView
@GetMapping("foo")
public ModelAndView foo(){
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("foo/index.html");
return modelAndView;
}
spring.profiles.active和spring.config.activate.on-profile区别
spring config profile
- https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#features.external-config.files.profile-specific
- https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#application-properties.core.spring.config.activate.on-cloud-platform
--spring.config.name
--spring.config.location
--spring.config.import
--spring.profiles.default
--spring.profiles.active
--spring.profiles.include
--spring.config.activate.on-profile
authenticated()permitAll()
authenticated()是受保护的(也就是需要登录后访问的)
permitAll()是不受保护的(也就是无需登录即可访问的)
- 标签 spring