【发布时间】:2017-05-10 07:36:48
【问题描述】:
我正在尝试向我的 spring-handler 发送 get-request,但它不起作用。 我的处理程序:
@RequestMapping(value="/master_record/details")
public @ResponseBody String user(@RequestParam(value="user") String user_name,
@RequestParam(value="password") String password) {
return "/success";
}
还有我的 ajax 请求:
function toggleHistory(nuser, pw){
$.ajax({
type : "GET",
url : 'master_record/details',
data : {"user": nuser, "password": pw},
success : function(result) {
console.log("SUCCESS");
},
error : function(data, textStatus, errorThrown) {
console.log("Error is ", textStatus, errorThrown);
}
});
};
当我查看链接时,我看到:
http://localhost:8080/webapp/master/master/record?user=me&password=secret&_=149440118200
我看到第三个参数和值:_=149440118200 那是哪个参数?
错误日志
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
<title>Error 404 Not Found</title>
</head>
<body><h2>HTTP ERROR 404</h2>
<p>Problem accessing /webapp/master/master_record/details. Reason:
<pre> Not Found</pre></p><hr /><i><small>Powered by Jetty://</small></i><br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
</body>
</html>
【问题讨论】:
-
你的控制器类有@Controller吗?
-
不起作用是什么意思?
-
是的,我的控制器类有@Controller。其他路线运作良好。我的意思是,我看到这条消息:GET localhost:8080/webapp/master/master/… 404 (Not Found)
-
你能显示你的班级水平
@RequestMapping,我认为这是导致问题的原因!?
标签: ajax spring request-mapping