SpringMVC4.1中使用FastJson

pom.xml


	4.0.0
	com.dr
	spring4
	war
	0.0.1-SNAPSHOT
	spring4 Maven Webapp
	http://maven.apache.org

	
		4.1.4.RELEASE
	

	
		
			junit
			junit
			3.8.1
			test
		

		
		
			org.springframework
			spring-context
			${springframework.version}
		
		
			org.springframework
			spring-orm
			${springframework.version}
		
		
			org.springframework
			spring-web
			${springframework.version}
		
		
			org.springframework
			spring-webmvc
			${springframework.version}
		

		
		
			com.alibaba
			fastjson
			1.2.4
		

	
	
		spring4
	

Java代码

package com.dr.controller;

import java.util.HashMap;
import java.util.Map;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.dr.model.APP;

@RestController
public class DemoController {

	@RequestMapping("/info.do")
	public String getInfo() {
		return "Hello World!";
	}

	@RequestMapping("/map.do")
	public Map getMap() {
		Map map = new HashMap<>();
		map.put("a", "张三");
		map.put("b", "李四");
		map.put("d", "D");
		map.put("c", "张三丰");
		map.put("e", "E");
		map.put("f", "F");
		return map;
	}

	@RequestMapping("/app.do")
	public APP getApp() {
		APP app = new APP();
		app.setId("安卓");
		app.setVersion("5.0");
		return app;
	}

}

spring-servlet.xml




	
	

		
			
		

	

	
	


web.xml




  Archetype Created Web Application
  
  
	
		SpringMVC
		org.springframework.web.servlet.DispatcherServlet
		
			contextConfigLocation
			classpath:spring-servlet.xml
		
		1
	

	
		SpringMVC
		*.do
	
	
	
	
		SpringEncoding
		org.springframework.web.filter.CharacterEncodingFilter
		
			encoding
			UTF-8
		
	
	
		SpringEncoding
		/*
	



你可能感兴趣的:(Spring4)