首页 > spring mvc

spring mvc @ResponseBody 返回JSON数据 The resource identified by…

status406

在springmvc 通过URL请求数据返回JSON时,报错 The resource identified by this request is only capable of generating responses with characteristics not acceptable according to the request “accept” headers. 问题原因为未在pom文件中引入json的转换包。 解决办法: 1、在pom.xml中添加json所需要的依赖 2、spring-mvc.xml 加入: 配置后,成功返回:   &nbsp … 阅读全文

@RequestMapping 注释类型作用及value属性用法

在控制器类的内部为每一个动作开发相应的处理方法。要让Spring知道用哪一种方法来 处理它的动作,需要使用RequestMapping注释类型映射的URL与方法。 RequestMapping注释类型的作用:映射一个请求和一种方法。可以使用@RequestMapping注释一种方法或类。 一个采用@RequestMapping注释的方法将成为一个请求处理方法,并由调度程序在接收到对应URL请求时调用。 @Controller public class CustomerController { @RequestMapping (value = “/customer_input&#82 … 阅读全文