ajax url在localhost上工作正常,但在服务器java servlet tomcat托管服务器上给出404

时间:2019-05-01 15:46:24

标签: java maven spring-mvc servlets

我已经在localhost上完成了我的应用程序,并且工作正常,但是我 上传到服务器时遇到问题。

这是我的Ajax本地代码,运行正常。

  $.ajax({
      type: "get",
      url: "http://localhost:8080/Certificates/ViewCertificates",
      dataType: "JSON",
     success: function (data) {
     console.log(data); 
     }
   });

but when am upload to my domain and change url to example

 http://example.com/Certificates/ViewCertificates

  it gives me 404 error on the ajax call. i have tried many solutions that are given on stackoverflow and other platforms but none of them is giving me success. 

here is my web.xml mapping
<servlet>
    <servlet-name>ViewCertificates</servlet-name>
    <servlet-class>Controller.ViewCertificates</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>ViewCertificates</servlet-name>
    <url-pattern>/ViewCertificates</url-pattern>
</servlet-mapping> 

 it will be highly appreciated if anyone can give me hint or a link which i can read to solve this out.

0 个答案:

没有答案