Ajax請求返回406 Not Acceptable

Ajax請求返回406 Not Acceptable

 

引入jackson相關jar包(不清楚那個必須,直接全部都引入)

 

修改Spring配置

        <!-- 加入json支持 -->
	<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
		<property name="messageConverters">
			<list>
				<!-- 設置返回字符串編碼 -->
				<bean class="org.springframework.http.converter.StringHttpMessageConverter">
					<property name="supportedMediaTypes">
						<list>
							<value>text/html;charset=UTF-8</value>
						</list>
					</property>
				</bean>
				<!-- json轉換器 -->
				<bean class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter">
					<property name="supportedMediaTypes">
						<list>
							<value>text/html;charset=UTF-8</value>
							<value>application/json;charset=UTF-8</value>
							<value>application/x-www-form-urlencoded;charset=UTF-8</value>
						</list>
					</property>
				</bean>
			</list>
		</property>
	</bean>

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章