Java Spring:Http406此请求标识的资源只能

Java Spring:Http406此请求标识的资源只能,java,spring,http,tomcat,Java,Spring,Http,Tomcat,我使用Spring4.0.0、SpringMVC,我有jackson-core-asl-1.9.13.jar、jackson-mapper-asl-1.9.13.jar 此请求标识的资源只能根据请求“接受”标头生成具有不可接受特征的响应 我的控制器 @RequestMapping(value="login.do",method= RequestMethod.POST) @ResponseBody public ServerResponse<User> login(String use

我使用Spring4.0.0、SpringMVC,我有
jackson-core-asl-1.9.13.jar、jackson-mapper-asl-1.9.13.jar

此请求标识的资源只能根据请求“接受”标头生成具有不可接受特征的响应

我的控制器

@RequestMapping(value="login.do",method= RequestMethod.POST)
@ResponseBody
public ServerResponse<User> login(String username, String password, HttpSession session){
    ServerResponse<User> response = iUserService.login(username,password);
    if(response.isSuccess()){
        session.setAttribute(Const.CURRENT_USER,response.getData());
    }
    return response;
}
@RequestMapping(value=“login.do”,method=RequestMethod.POST)
@应答器
公共服务器响应登录(字符串用户名、字符串密码、HttpSession会话){
ServerResponse=iUserService.login(用户名、密码);
if(response.issucess()){
setAttribute(Const.CURRENT_USER,response.getData());
}
返回响应;
}
我的dispatcher-servlet.xml已经有了内容。这些是文件的一部分

 xsi:schemaLocation="
   http://www.springframework.org/schema/beans
   http://www.springframework.org/schema/beans/spring-beans-3.1.xsd

 <mvc:annotation-driven>
    <mvc:message-converters>
        <bean class="org.springframework.http.converter.StringHttpMessageConverter">
            <property name="supportedMediaTypes">
                <list>
                    <value>text/plain;charset=UTF-8</value>
                    <value>text/html;charset=UTF-8</value>
                </list>
            </property>
        </bean>
        <bean class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter">
            <property name="supportedMediaTypes">
                <list>
                    <value>application/json;charset=UTF-8</value>
                </list>
            </property>
        </bean>
    </mvc:message-converters>
</mvc:annotation-driven>
xsi:schemaLocation=”
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
文本/纯文本;字符集=UTF-8
text/html;字符集=UTF-8
application/json;字符集=UTF-8
但我用的是调试,没关系。

然后我使用网络,它不工作。

根据您的调试图片,您需要
用户
,我猜
json
-ised


只需返回
User
,而不是
ServerResponse

response
是我的json数据,我需要
response
而不是
User
,因为
User
只是用户的数据,它没有
msg
,'status','data'。