这是我的休息控制器:
@RestController
public class LoginController {
@Autowired
private AppInstances appInstances;
@RequestMapping(method = RequestMethod.POST, value = "/signup")
public ResponseEntity<?> signup(@RequestBody SignupForm form) throws Exception
{
ResponseEntity<?> validate = FormFieldValidator.validate(form);
if(validate.getStatusCode() != HttpStatus.OK)
return validate;
else
{
return SignupService.signup(form, appInstances);
}
}
这是HTML表单
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h1>Hello World!</h1>
<form method="post">
<input type="text" name="userType" value="USER"/><br>
<input type="text" name="pwd" value="123456"/><br>
<input type="text" name="rpwd" value="123456"/><br>
<input type="text" name="name" value="manish kumar"/><br>
<input type="text" name="sex" value="Male"/><br>
<input type="text" name="bizzCategory" value="Restaurant"/><br>
<button>OK</button>
</form>
<script src="jquery.js"></script>
<script>
var formData = $("form").serializeArray();
var jsonData={};
$(formData).each(function(i,o){
console.log(o.name+"==="+o.value);
jsonData[o.name] = o.value;
});
$.ajax({
url:"http://localhost:8084/mobapp/signup",
type:"POST",
contentType:"application/json",
data:JSON.stringify(jsonData)
}).done(function(d){
alert(JSON.stringify(d));
}).error(function(e){
alert(e);
});
</script>
</body>
</html>
这是它在萤火虫中的表现。顺便说一句,它没有任何反应。
OPTIONS signup 200 OK localhost:8084
我使用的是spring security 4.0.1。