我有一個Java服務器,在Spring框架下有多個GET和POST請求,工作得很好現在,我在我的項目中創建了一個jsp文件創建一個簡單的表單(CustomerID,Title,Message)。在點擊表單的提交按鈕時,我想以JSON格式將表單數據發佈到我的服務。當我觸發時,此服務調用(POST請求)工作得很好它使用的是高級REST客戶端,但是當在Tomcat服務器上部署該表單時,該表單的特定前端沒有在瀏覽器中打開,而是在屏幕上顯示「沒有找到服務」'沒有發現服務。'在Spring和jQuery(ajax調用)中出現錯誤
擺弄我的web.xml後,我意識到如果我刪除以下代碼:
<servlet>
<servlet-name>CXFServlet</servlet-name>
<servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>CXFServlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>ecvServlet</servlet-name>
<servlet-class>com.***.platform.ecvcheck.NodeStatusServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>ecvServlet</servlet-name>
<url-pattern>/node</url-pattern>
</servlet-mapping>
從我的web.xml,然後form.jsp文件打開就好了。但是,GET和POST請求(即使是與form.jsp無關的請求)都不起作用。正因爲如此,沒有服務會被點擊提交按鈕。
我最後的web.xml看起來是這樣的:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
id="WebApp_ID" version="3.1">
<display-name>feedex-app</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>WEB-INF/appContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>
<listener>
<listener-class>com.***.platform.config.PlatformContextLoaderListener</listener-class>
</listener>
<display-name>feedex-app</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
是否有人可以幫助我如何將前端位在Tomcat服務器(Web應用程序)?
謝謝!
放置前端文件的位置? – Ghayel
在webapp文件夾(WEB-INF外部)。 – Somya