Spring MVC 3.2 ajax 406 수정 설정

2090 단어 springmvcAjax4063.2
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:mvc="http://www.springframework.org/schema/mvc"
	xsi:schemaLocation="http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
       http://www.springframework.org/schema/context
       http://www.springframework.org/schema/context/spring-context-3.2.xsd
       http://www.springframework.org/schema/mvc
       http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd">

	<context:component-scan base-package="*" />
	<mvc:annotation-driven content-negotiation-manager="contentNegotiationManager" />
	<bean id="contentNegotiationManager"
		class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean">
		<property name="favorPathExtension" value="false" />
		<property name="favorParameter" value="false" />
		<property name="ignoreAcceptHeader" value="false" />
		<property name="mediaTypes">
			<value>
				atom=application/atom+xml
				html=text/html
				json=application/json
				*=*/*
			</value>
		</property>
	</bean>
	...
</beans>

화면 음악 c - 3.2. xsd
http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd">

jackson - core, jackson - mapper 두 개의 jar 가방 가 져 오기
컨트롤 러 중
@RequestMapping(value="/checkUserName")
public @ResponseBody Map<String, Object> checkUserName(@RequestBody User user){
    Map<String, Object> resultMap = new HashMap<String, Object>();
    return resultMap;
}

MVC 는 프론트 데스크 의 JSON 데 이 터 를 User 로 자동 변환 하고 맵 을 JSON 으로 자동 변환 하여 프론트 데스크 로 되 돌려 줍 니 다.

좋은 웹페이지 즐겨찾기