[英]HTTP status 404 while calling ajax url
I have a form which has submit button and button.我有一个带有提交按钮和按钮的表单。 I am implementing an ajax cal for a button using get method.
我正在使用 get 方法为按钮实现 ajax cal。 I have passed value in url.
我已经在 url 中传递了值。 and while clicking on button, it is making an ajax cal.
在单击按钮时,它正在执行 ajax cal。 but in the middle before success function, stopping abruptly.
但是在成功之前的中间函数,突然停止。 If I see in "Show Command Line Popup" in mozilla, I am able to see the error status:404."The requested resource is not available".
如果我在 mozilla 的“显示命令行弹出窗口”中看到,我可以看到错误状态:404。“请求的资源不可用”。
I am using thymeleaf and spring mvc.我正在使用百里香叶和弹簧 mvc。 below is my ajax cal
下面是我的 ajax cal
<script type="text/javascript">
function process(){
alert("button clicked");
$.ajax({
url:'searchabc',
}).done(function (){
alert("success");
});
}
</script
and spring method:和弹簧方法:
@RequestMapping(value = "xxx/yyy/searchabc", method = RequestMethod.GET)
public String searchabc(Model model){
log.debug("hello");
return "helloworld";
}
Just change:只是改变:
url:'./searchabc',
To:到:
url:'searchabc',
You may need to add @ResponseBody
.您可能需要添加
@ResponseBody
。 Please also validate the url.还请验证网址。 Also it will be useful if you share the url mapping from application context and web.xml
如果您从应用程序上下文和 web.xml 共享 url 映射也会很有用
@RequestMapping(value = "xxx/yyy/searchabc", method = RequestMethod.GET)
public @ResponseBody String searchabc(Model model){
log.debug("hello");
return "helloworld";
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.