我有一个如下控制器
@Controller
public class SettingsController {
@RequestMapping(value="/editname",method=RequestMethod.POST)
public void editName(@RequestParam(value="firstname") String firstname,
@RequestParam(value="lastname") String lastname) {
final Object principal =
SecurityContextHolder.getContext().getAuthentication().getPrincipal();
try {
jdbcPersonRepository.updateName(principal.toString(), firstname, lastname);
} catch (SignInNotFoundException e) {
}
}
}
我有我的 ajax 表单提交。
$(function() {
//twitter bootstrap script
$("button#submit").click(function(){
var $form = $(this).closest("form");
var type = $form.attr('method');
$.ajax({
type: $form.attr('method'),
url: $form.attr('action'),
data: $form.serialize(),
dataType : "json",
success: function(msg){
$("#thanks").html(msg)
$("#form-content").modal('hide');
},
error: function(){
//alert("failure");
}
});
});
});
我的 twitter bootstrap 模型具有触发 ajax 的形式如下
<!-- Name Edit div -->
<div id="form-content" class="modal hide fade in" tabindex="-1">
<form name="edit-form" action="<c:url value="/editname" />" method="post">
<div class="modal-header">
<h4>Edit Name</h4>
</div>
<div class="modal-body">
<div class="control-group">
<div class="controls">
<ul class="nav nav-list">
<li class="nav-header">First Name</li>
<li><input type="text" placeholder="First Name" name="firstName" id="firstName" class="input-xlarge help-inline"></li>
<li class="nav-header">Last Name</li>
<li><input type="text" placeholder="Last Name" name="lastName" id="lastName" class="input-xlarge help-inline"></li>
</ul>
</div>
</div>
</div>
<div class="modal-footer">
<button id="submit" class="btn btn-success">Update</button>
<button class="btn" data-dismiss="modal" >Close</button>
</div>
</form>
</div>
有没有人知道这个错误。?