gpt4 book ai didi

javascript - 使用ajax从外部html页面调用tomcat服务器war url

转载 作者:行者123 更新时间:2023-11-28 23:27:29 24 4
gpt4 key购买 nike

我正在使用 apache-tomcat-7.0.67 并在 webapps 文件夹 War name 下部署了一个 jar::

Account

war 是使用 spring-boot 创建的,所以没有显式定义 web.xml ,但是 url 映射是使用 @RequestMapping(value="/submitForm",method = RequestMethod.POST)当我从 PostmanJMeter 访问此 url 时,如 http://localhost:8080/Account/submitForm 请求到达服务器,响应是回。
现在我有另一个文件夹,里面只包含 html 文件,这些文件不像 war 一样 enter image description here

它有一些 html 文件,其中包含使用 javascript 的 ajax 调用

$.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' 之后,请求也永远不会到达服务器,谁能告诉我如何解决这个问题,我完全被卡住了.

最佳答案

也许你不应该使用你的 war 的名字

我在这里使用这样的请求

$.ajax( ... url: "../GUI/ResponseTime", ...

还有我类的这个注解

@WebServlet(name = "ResponseTime", urlPatterns = {"/GUI/ResponseTime"})

无论文件的 war 名称如何,它都有效

关于javascript - 使用ajax从外部html页面调用tomcat服务器war url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35115565/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com