我正在使用带有JSON的Spring MVC,如Ajax Simplification Spring 3.0文章中所指定的那样.
根据各种论坛上的建议,在我的代码进行了如此多的尝试和变化之后,我的代码仍然不起作用.
我继续收到以下错误:(406)此请求标识的资源只能根据请求"accept"headers()生成具有不可接受特征的响应.
我根据需要在appconfig.xml中.
APP-config.xml中
<context:component-scan base-package="org.ajaxjavadojo" />
<!-- Configures Spring MVC -->
<import resource="mvc-config.xml" />
Run Code Online (Sandbox Code Playgroud)
MVC-config.xml中
<mvc:annotation-driven />
<!-- Forwards requests to the "/" resource to the "index" view -->
<mvc:view-controller path="/" view-name="index"/>
<!-- Resolves view names to protected .jsp resources within the /WEB-INF/views directory -->
<bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
<property name="mediaTypes">
<map>
<entry key="html" value="text/html"/>
<entry key="json" value="application/json"/>
</map>
</property>
<property name="viewResolvers">
<list>
<bean class="org.springframework.web.servlet.view.BeanNameViewResolver"/>
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/views/"/>
<property name="suffix" value=".jsp"/>
</bean> …Run Code Online (Sandbox Code Playgroud)