为什么ajax总是404,AJAX的404失败了……但还是管用?什么给予?

博主在尝试通过AJAX发送用户选择的项目信息到SpringMVC控制器,但遇到了404错误。尽管服务器成功接收并返回了StatusResponse对象,客户端却报告页面未找到。问题可能在于响应类型或URL配置不匹配。寻求解决方案。
摘要由CSDN通过智能技术生成

Maybe I should just keep my mouth shut and move forward, but something tells me things aren't working as nicely as I think they are and I need to fix it.

Basically, I'm doing a simple AJAX call to tell the server what the user has selected: an already existing project or a new project. The AJAX looks like this:

var dataString = 'existingProject='+ $("#existingProject").val() + '&newProjName=' + $("#newProjName").val();

//AJAX call to post selections to server

$.post('/myproj/manageProjects.html',dataString);

The Spring MVC signature that handles this post call looks like this:

@RequestMapping(value="/manageProjects",produces="application/json",method=RequestMethod.POST)

public StatusResponse manageProjects(

@RequestParam(value="existingProject",required=false) String existingProj,

@RequestParam(value="newProjName",required=false) String newProj,

HttpSession session){

What's blowing my mind is, I am getting the call into manageProjects with the correct variables and values I expect. The server handles the request and returns a pojo I created called StatusResponse wrapping a boolean (success or failure) and a list of server feedback messages. I create one with the simple status of "true" for success and pass it back.

The client then throws up a 404 manageProjects.html not found and continues on its merry way as though nothing has gone wrong.

So....did it find it or not? If a StatusResponse-type pojo is an inappropriate response from a Spring MVC controller, what IS the right response? Why would the message successfully hit the controller but then the client receive a 404?!

Thanks for any insight....

Footnote: apologies if this looks similar to an earlier question from today. I came at the core problem from the wrong angle and created more confusion than necessary in that posting...

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值