- 필요한 library
- dispatcher-servlet.xml
- bean id="jsonView" <-- 중요!!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
<!-- Ajax json start-->
<bean id="jsonView" class="org.springframework.web.servlet.view.json.MappingJacksonJsonView">
<property name="contentType" value="application/json;charset=UTF-8"/>
</bean>
<bean id="beanNameResolver" class="org.springframework.web.servlet.view.BeanNameViewResolver" p:order="0"/>
<bean id="jacksonMessageConverter" class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter"/>
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<property name="messageConverters">
<list>
<ref bean="jacksonMessageConverter"/>
</list>
</property>
</bean>
<!-- Ajax json end -->
| cs |
- Ctrl 단
1
2
3
4
5
6
|
@RequestMapping("Ajax 데이터를 받을곳")
public ModelAndView mavtest2(String id){
//ViewName을 bean class 의 id로 선언
//알아서 잘들어감~
mav.setViewName("jsonView");
return mav;
}
| cs |
댓글 없음:
댓글 쓰기