1
Jquery
에 Spring MVC
을 사용하고 있습니다. Jquery에서 Ajax 함수가 400 오류를 반환합니다.
내가
는이index.jsp
하나는 내가 jQuery를 함께
$ajax
를 실행 입력 상자에 문자를 삽입 할 때 당신이 볼 수 있듯이
<html>
<head>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"
integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7"
crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css"
integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r"
crossorigin="anonymous">
<!-- Latest compiled and minified JavaScript -->
<script
src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"
integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS"
crossorigin="anonymous">
</script>
<script
src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js">
<script type="text/javascript">
</script>
<script>
$(document).ready(function() {
$("input").keyup(function() {
$.ajax({
url : "myController",
type: "POST",
data: $("#name").val(),
success : function(result) {
alert(result);
}
});
});
});
</script>
</head>
<body>
<form>
<div class="row">
<div class="col-sm-12">
<label for="name">Name:</label>
</div>
<div class="col-sm-1">
<input type="text" class="form-name" id="name" placeholder="Paolo">
</div>
</div>
</form>
</body>
</html>
. 내 HTTP POST 요청이 정확하지만 400 오류가 있습니다.
이 내 간단한 컨트롤러 클래스 :
@Controller
public class MyController {
@RequestMapping(value="/myController", method = RequestMethod.POST)
@ResponseBody
public String getData(@RequestParam(value="name") String name) {
return name;
}
}
는 스프링 MVC에 대한 나의 DispatcherServlet이이 correclty
을 잘 살고있다. 어떻게 해결할 수 있습니까?
는'데이터를 시도 할 것입니다 : {이름 :. $ ("# 이름") 발()}' –
내가 시도했지만 작동하지 않습니다. 동일한 400 개의 잘못된 요청 오류가 있습니다. – DistribuzioneGaussiana
이 오류가 발생하면 서버의 스택 추적을 추가 할 수 있습니까? –