【发布时间】:2014-06-08 18:33:38
【问题描述】:
我正在使用 eclipse 和 Jboss 编写一个简单的 Spring MVC 应用程序。 我创建了一个企业应用程序,并在 application.xml 中将上下文根设置为 myAppWeb。
我的 web.xml 详细信息:
<servlet>
<servlet-name>springapp</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>springapp</servlet-name>
<url-pattern>*.htm</url-pattern>
</servlet-mapping>
我的 springspringapp-servlet.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"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd">
<!-- the application context definition for the springapp DispatcherServlet -->
<bean name="/a.htm" class="com.init.servlet.test.HelloController" />
</beans>
现在当我输入 URL 为
"http://localhost:8080/myAppWeb/a.htm"
我收到 404 错误,日志消息为:
" servlet.PageNotFound OO noHandlerFound() OO No mapping found for HTTP request with URI [/myAppWeb/a.htm] in DispatcherServlet with name 'springapp'".
我将 springspringapp-servlet.xml 中的配置更改为
<bean name="/myAppWeb/a.htm" class="com.init.servlet.test.HelloController" />
仍然无法正常工作。
有人可以帮我解决这个问题吗?
谢谢!
【问题讨论】:
-
您认为
<bean>的name属性有什么作用,为什么? -
你需要发布HelloController的代码
标签: java eclipse spring jakarta-ee spring-mvc