spring3.2
@RequestMapping(value="/findTypeInfo",produces="text/html;charset=UTF-8")
@ResponseBodypublic String findTypeInfo(String productId) throws BaseException{
String result="";
try {
result = productService.findTypeInfoByProductId(productId);
}catch(Exception e){
throw new BaseException("SerachTypeInfoException", e, SaleErrorCode.SALE_ERROR_SERACHTYPEINFO);
}
return result;
}
只要加上produces="text/html;charset=UTF-8"即可
spring3.0
<!-- 启动Spring MVC的注解功能,完成请求和注解POJO的映射 -->
<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>
</list>
</property>
</bean>