1
spring mvcで少しデモを行っています。アプリケーションを配備する際に問題があります。私は私のweb.xmlのHTTP用のマッピングが見つかりませんでした。Spring MVC
私のアプリ-config.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>
を何が起こっているか理解していないwildfly 10.0.0
Inを使用しています
<?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");
}
}
アプリケーションがデプロイされると、次のエラーがあなたのコントローラがSpringアプリケーションによってscanedされていないかもしれ思わコンソール
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がそのような問題を引き起こすのかを知っています 設定やコードでは何も変更していませんでした。 –