修改http头实现跨域

index.html





jsonp







jsonp.java

package com.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class Jsonp {
	@ResponseBody
	@RequestMapping("/jsonpdata.do")
	public String doo(@RequestParam String funcName) {
		String value = "{userName:'happy'}";
		String from = "'china'";
		String res = funcName + "(" + value + "," + from + ");";
		return res;
	}

	@RequestMapping("/jsonp.do")
	public String doo() {
		return "jsonp";
	}
}


你可能感兴趣的:(跨域)