我已经为GET restTemplate实现了@before建议。由于GET调用没有任何@requestparam,因此joinPoint从调用中获取HttpServletRequest。
<form>
@Html.TextBoxFor(m => m.Name, new { @class = "form-control" })
<span id="spanFirstName" class="alert-danger"></span>
@Html.TextBoxFor(m => m.Email, new { @class = "form-control"})
<span id="spanEmail" class="alert-danger"></span
@Html.TextBoxFor(m => m.ConfirmEmail, new { @class = "form-control"})
<span id="spanConfirmEmail" class="alert-danger"></span>
<input type="submit" data-attr="SendEmail" class="btn btn-primary" value="Post" />
</form>
但是当我尝试使用objectmapper.writeValueAsString时,它将引发错误
$(document)
.on("keypress", "#Email", function (e) {
if ($('#Email').val().indexOf('*') !== -1) {
$('#hiddenEmail').val($('#hiddenEmail').val());
}
else {
$('#hiddenEmail').val($('#Email').val());
}
});
$(document)
.on("keypress", "#ConfirmEmail", function (e) {
if ($('#Email').val() !== null || $('#Email').val() !== '')
{
$('#Email').val($('#Email').val().replace(/[^\s]/g,"*"));
}
});
$(document)
.off("click", "[data-attr='SendEmail']")
.on("click", "[data-attr='SendEmail']", function (e) {
validate();
});
function validate() {
var firstName = $('#Name').val();
var email = $('#Email').val();
var confirmEmail = $('#ConfirmEmail').val();
var hiddenEmail = $('#hiddenEmail').val();
if (hiddenEmail !== "" && confirm !== "") {
if (hiddenEmail !== confirmEmail) {
$('#spanConfirmEmail').text('Email Addresses do not match');
}
else {
$('#spanConfirmEmail').text('');
}
}
}
与joinPoint一起使用@requestParam中存在的对象一样,它们也可以正常工作POST方法