1:![](https://img-blog.csdn.net/20170901170629639?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvcXE4NTM0NDc5MTc=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center)
@RestController
public class ApiRestController {
protected Logger logger = LoggerFactory.getLogger(getClass());
@Autowired
private JfAccountService jfAccountService;
@Autowired
private JfDetailService jfDetailService;
//
@RequestMapping("/jiekou")
public String returnXml(ModelMap modelMap, HttpServletRequest request, HttpServletResponse response){
logger.info("进入调用接口的方法中 returnXml*****************begin");
response.setHeader("Content-type", "text/html;charset=UTF-8");
String IDNO ="";
}
返回字符串 字符串是xml格式的 里面的中文乱码
返回xml乱码 解决方法是在配置文件中加个配置
@RestController
public class ApiRestController {
protected Logger logger = LoggerFactory.getLogger(getClass());
@Autowired
private JfAccountService jfAccountService;
@Autowired
private JfDetailService jfDetailService;
//
@RequestMapping("/jiekou")
public String returnXml(ModelMap modelMap, HttpServletRequest request, HttpServletResponse response){
logger.info("进入调用接口的方法中 returnXml*****************begin");
response.setHeader("Content-type", "text/html;charset=UTF-8");
String IDNO ="";
}
<mvc:annotation-driven> <mvc:message-converters register-defaults="true"> <bean class="org.springframework.http.converter.StringHttpMessageConverter"> <!--先进行string转换-->
</bean> <bean class="com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter"> <property name="supportedMediaTypes"> <list> <value>text/html;charset=UTF-8</value> <value>application/json</value> </list> </property> <property name="features"> <list> <value>WriteMapNullValue</value> <value>QuoteFieldNames</value> <value>WriteDateUseDateFormat</value> </list> </property> </bean> </mvc:message-converters></mvc:annotation-driven><constructor-arg value="UTF-8" />