[英]Spring Boot + Bootstrap + jQuery : Error 404 in $ajax call on Firefox
我有一个使用 Spring Boot + Bootstrap + Thymeleaf 的应用程序。 我正在尝试使用 jquery 调用 AJAX 来填充组合框。 在 Chrome 中运行良好。 在 Firefox 中给了我 404 消息。 会发生什么?
Firefox console.log 消息:
我的 AJAX 代码:
function carregaComboAtivoAjax(url) {
var Id = document.getElementById('idUo').value;
$.ajax({
url: url,
dataType: 'html',
data: { Id: Id },
success: function(data) {
if (data != null) {
$("body").html(data);
}
}
});
}
我的 Controller 代码:
@RequestMapping(value = "/carregaComboAtivoCadastraCampo", method = RequestMethod.GET)
private String carregaComboAtivo(@RequestParam UUID Id, Model model) {
...
}
最好的,
如果你有同样的问题,那就是解决方案:
在 spring 启动 controller 方法中,您需要这样编写:
@RequestMapping(value = "/carregaComboAtivoCadastraCampo", method = RequestMethod.GET, produces = { MediaType.TEXT_HTML_VALUE })
@ResponseBody
public ModelAndView carregaComboAtivo(@RequestParam UUID uoId, Model model) {
...
}
您需要设置媒体类型产生。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.