此问题不是重复的,指向其他问题的链接不能解决此问题。带弹簧启动!我正在尝试使用javascript xmlhttprequest()获得响应,但是在我的jsp中却得到了空白响应。我想得到“ hi”作为回应,我该怎么做才能使其在Spring Boot中正常工作?
我的控制器:
@Controller
public class Intro2 {
@ResponseBody
@RequestMapping(value = "/intro2", method = RequestMethod.GET)
public String show(){
return "hi";
}
我的jsp:
var xhttp = new XMLHttpRequest();
xhttp.open("GET", "localhost:8080/intro2", true);
xhttp.send();
var text = xhttp.responseText;
var target = document.getElementById("main");
target.innerHTML = text;}