Java 在spring boot中停止响应的默认jsonification?
这是我的控制器方法Java 在spring boot中停止响应的默认jsonification?,java,spring-boot,Java,Spring Boot,这是我的控制器方法 @RequestMapping(value = "/employee", method = RequestMethod.GET) public ModelAndView listEmployees(HttpServletRequest request) { List<Employee> employees = employeeService.getList(); return new ModelAndView("hell
@RequestMapping(value = "/employee", method = RequestMethod.GET)
public ModelAndView listEmployees(HttpServletRequest request) {
List<Employee> employees = employeeService.getList();
return new ModelAndView("hello").addObject("employees", employees);
}
@RequestMapping(value=“/employee”,method=RequestMethod.GET)
公共模型和视图列表员工(HttpServletRequest){
List employeeService.getList();
返回新的ModelAndView(“hello”).addObject(“employees”,employees);
}
这是我的相关pom
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
org.springframework.boot
SpringBootStarterWeb
我看到employees对象自动转换为json
然后我试着
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</exclusion>
</exclusions>
</dependency>
org.springframework.boot
SpringBootStarterWeb
com.fasterxml.jackson.core
杰克逊数据绑定
但结果仍然是转换成json 您是否将控制器注释为
@RestController
而不是@controller
?第一个默认为JSON响应。您的hello
页面中有什么内容?