我需要将浏览器时区传递回我的控制器,并且我通过在jsp中使用隐藏的表单字段来完成此操作。我使用jQuery val方法设置值。但是,在Controller上检索的值是""。你能帮忙吗?
JSP - Spring表单标签: `
<div data-role="content" style="text-align: center">
<form:form id="user" modelAttribute="user" action="index">
<form:input path="accountNumber" id="account-number"
placeholder="Account Number"/>
<form:hidden path="timeZone" id="timeZone" value=""/>
</form:form>
</div>
`
jQuery方法:
$(document).ready(function() {
var zone = Intl.DateTimeFormat().resolvedOptions().timeZone;
$("#timeZone").val(zone);
});