我正在处理基于 Spring-MVC Web 的应用程序。我使用 Freemarker 和 JQuery。@Freemarker,我有以下 JQuery,它应该去后端两次:
$(document).ready(function() {
var date = new Date();
var d = date.getDate();
var m = date.getMonth();
var y = date.getFullYear();
$.getJSON('[@spring.url '/vacation/loadResourceVacation'/]', function (data) {
$.getJSON('[@spring.url '/vacation/loadPublicVacations'/]', function (returnedPublicVacation) {....
2个java方法是:
@RequestMapping(value = "/loadResourceVacation", method = RequestMethod.GET)
public
@ResponseBody
String loadResourceVacation(HttpServletResponse response) throws Exception {
// Convert to JSON string.
String json = new Gson().toJson(myObject);
// Write JSON string.
response.setContentType("application/json");
response.setCharacterEncoding("UTF-8");
return json;
}
@RequestMapping(value = "/loadPublicVacations", method = RequestMethod.GET)
public
@ResponseBody
String loadPublicVacations(HttpServletResponse response) throws Exception {
// Convert to JSON string.
String json = new Gson().toJson(someObj);
// Write JSON string.
response.setContentType("application/json");
response.setCharacterEncoding("UTF-8");
return json;
}
@Google Chrom,它工作得非常好。但是@ IE,它在我第一次加载页面时工作正常。如果我再次尝试加载页面,则不会调用这 2 个方法,并且会从第一次开始缓存。
如果我关闭会话并打开一个新会话,则将再次调用这 2 个方法。任何帮助!