【发布时间】:2016-01-31 15:29:10
【问题描述】:
我正在使用 apache-tomcat-7.0.67 和 webapps 文件夹 War name ::
Account
war 是使用 spring-boot 创建的,所以没有明确定义 web.xml,但 url 映射已经使用 @RequestMapping(value="/submitForm",method = RequestMethod.POST) 定义
当我从 Postman 或 JMeter (如http://localhost:8080/Account/submitForm)点击此 URL 时,请求到达服务器并返回响应。
现在我有另一个文件夹,其中只包含 html 文件,这些文件不像战争那样
它有一些 html 文件,其中包含 ajax 使用 javascript 之类的调用
$.ajax({
type: 'POST',
url: '/Account/submitForm',
success: function (resp) {
console.log(resp);
},
error: function(e) {
console.log('Error: ',e);
}
});
但是即使使用 url: 'https://localhost:8080/Account/submitForm' ,请求也永远不会到达服务器,谁能告诉我如何解决这个问题,我完全卡住了。
【问题讨论】:
-
你怎么知道请求“从未到达服务器”?将文件放在
webapps/html中意味着它们是从/Account上下文中的servlet 上下文(“Web 应用程序”)提供的。 -
我是从 Firebug 的 Net 面板中了解到的,它显示状态
Aborted,对不起,我没有像你所说的那样means they are being served from a servlet context ("web app") from the /Account context请详细说明
标签: javascript java ajax spring tomcat