0

次のSpring Controllerがあります

@Controller
@RequestMapping("/accreq")

org.springframework.samples.mvc.ajax.account.AvailabilityStatus次のマッピングと追加のブール値フィールドと同様のファイルsomeBooleanValue

@RequestMapping(value = "/defRoles", method=RequestMethod.GET)
public @ResponseBody AvailabilityStatus loadDefaultRoles(
    @RequestParam(value="idGroup", required=false) String groupID {

次のjquery ajaxでこのメソッドを呼び出そうとしています

$.getJSON("${pageContext. request. contextPath}/accreq/defRoles.htm", { idGroup: $('#infoGroup').val() }, function(availability) {
        if (availability.someBooleanValue) {
            //Do this
        } else {
            //Do else
        }
    });

Spring メソッドを実行していますが、406応答が返ってきます。dataType正常な応答を得るために何を設定する必要がありますか? これは以前は下で動作していましたが、現在はまたはSpring 3.1.4のような上位バージョンの Spring では動作しません。要するに、Ajax 応答でオブジェクトの戻りを処理する方法は?3.2.44.0.0

応答ヘッダー -406エラー

Request Headersview source
Accept  application/json, text/javascript, */*; q=0.01
Accept-Encoding gzip, deflate
Accept-Language en-US,en;q=0.5
Connection  keep-alive

設定

<context:component-scan base-package="com.X" />
<mvc:annotation-driven />
<cache:annotation-driven />
<bean class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor"/>

<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
    <property name="basename" value="messages" />
</bean>
...mapping for controller.....database etc

<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="viewClass" value="org.springframework.web.servlet.view.JstlView" />
    <property name="prefix" value="/WEB-INF/jsp/" />
    <property name="suffix" value=".jsp" />
    <property name="cache"  value="true" />
    <property name="order"  value="1" />
</bean>
4

1 に答える 1