配置信息没有出错,将注解@RestController改为@Controller,居然能够跳转到前端的页面了。
@Controller
public class TestController {
@Autowired
private BaseClassService baseClassService;
@ResponseBody
@RequestMapping("/hello")
public String hello(){
return "hellospringboot111"; //输出hellospringboot111
}
@ResponseBody
@RequestMapping("/test22")
public List<BaseClass> findAll(){
System.out.println("读取数据库");
return baseClassService.findAll();
}
@RequestMapping(value="/login2",method = RequestMethod.GET)
public String login2() { //可以跳转到ztree3.html页面
return "ztree3";
}
}
本文详细解析了在SpringBoot中,通过将@RestController更改为@Controller,如何实现从前端页面的正常跳转。并通过具体代码示例展示了如何使用@RequestMapping、@ResponseBody等注解进行RESTful API的开发。
2203





