当前位置: 代码迷 >> Ajax >> springmvc3支持ajax配备
  详细解决方案

springmvc3支持ajax配备

热度:233   发布时间:2013-03-10 09:38:39.0
springmvc3支持ajax配置

1. 在springmvc-servlet.xml里加上??? <mvc:annotation-driven />

写道
<!-- anotation配置,coin目录下的@Controller @Service等注解都能支持 -->
<context:component-scan base-package="coin"
resource-pattern="**/*Controller.class" />
<mvc:annotation-driven />
<!-- velocity配置, resourceLoaderPath=/velocity指向${WebRoot}/velocity位置 -->
<bean id="velocityViewResolver"
class="org.springframework.web.servlet.view.velocity.VelocityViewResolver">
<property name="cache" value="true" />
<property name="prefix" value="" />
<property name="suffix" value=".vm" />
<property name="contentType" value="text/html;charset=UTF-8" />
<property name="dateToolAttribute" value="dateTool" />
<property name="numberToolAttribute" value="numberTool" />
<property name="toolboxConfigLocation" value="WEB-INF/toolbox.xml" />
</bean>
<bean id="velocityConfig"
class="org.springframework.web.servlet.view.velocity.VelocityConfigurer">
<property name="resourceLoaderPath" value="/velocity" />
<property name="velocityProperties">
<props>
<prop key="input.encoding">UTF-8</prop>
<prop key="output.encoding">UTF-8</prop>
</props>
</property>
</bean>

?

?

2. 在Controller返回值上加上 ??? @ResponseBody

写道
@RequestMapping("/register.do")
@ResponseBody
public Map<String, Object> ignore(ModelAndView modelAndView, Long pageIndex, Long pageLength,
Long coinTypeId, String ignoreCodes) {



}

?

?

3.在pom.xml配置文件里引用 jackson-mapper-asl

?

写道
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.9.12</version>
</dependency>

?

  相关解决方案