spring mvc4 restful api 乱码问题

一,修改spring-mvc.xml

添加如下:

	
		
			
			
				
				
			
			
			
				
				
			
		
	

二,修改方法,添加编码

	@RequestMapping(value = "/get/{msg}", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
	@ResponseBody
	public String get(@PathVariable("msg") String msg) {
		String result = "[GET] Hello " + msg;
		return result;
	}



你可能感兴趣的:(java)