@Configuration public class WebConfig implements WebMvcConfigurer { @Override public void addViewControllers(ViewControllerRegistry registry) { registry.addViewController("/").setViewName("index"); registry.addViewController("/login").setViewName("login"); } } @Controller public class UserController { @GetMapping("/user/{id}") public String getUser(@PathVariable("id") String id, Model model) { return "userProfile"; } } RestTemplate restTemplate = new RestTemplate(); String result = restTemplate.getForObject("http://api.example.com/user/123", String.class);


上一篇:
下一篇:
切换中文