1
我正在使用spring mvc做一些演示,並且在部署應用程序時遇到問題。我使用wildfly 10.0.0未找到映射HTTP Spring MVC
在不明白什麼是我的web.xml中
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<display-name>Archetype Created Web Application</display-name>
<servlet>
<servlet-name>simu-cmac</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/app-config.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>simu-cmac</servlet-name>
<url-pattern>*.htm</url-pattern>
</servlet-mapping>
在我的應用程序-config.xml中
發生
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd">
<context:component-scan base-package="com.cmac.simu" />
<mvc:annotation-driven/>
我的控制器
@Controller
public class SimuAPIController {
protected final Log logger = LogFactory.getLog(getClass());
@RequestMapping("/home.htm")
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
logger.info("Returning home view");
System.out.println("To home view");
return new ModelAndView("home.jsp");
}
}
當應用程序被部署以下錯誤顯示在控制檯
19:50:39,417 WARN [org.springframework.web.servlet.PageNotFound] (default task-3) No mapping found for HTTP request with URI [/simu-cmac/home.htm] in DispatcherServlet with name 'simu-cmac'
你可以在tomcat中試試嗎?我只是想確定它是否是應用程序服務器的問題。 –
只需嘗試/home.htm。我無法看到爲/simu-cmac/home.htm設置的上下文路徑? – Barath
我將它部署在tomcat中,運行沒有問題,有人知道爲什麼wildfly會給出這些問題 我曾經改變過任何配置或代碼,只有服務器 –