Spring MVC 与 Weblogic 集成
每当我尝试在浏览器中查看教程应用程序时,我都会收到此错误
警告:在名为“dispatcher”的 DispatcherServlet 中未找到带有 URI [/HelloWorld.Web] 的 HTTP 请求的映射
这仅意味着调度程序 servlet 正在接收该请求,但无法将其转发到控制器。
但我似乎不知道问题出在哪里。我想我已经正确映射了:
<bean id="urlMapping"
class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<props>
<prop key="/HelloWorld.Web">indexController</prop>
</props>
</property>
</bean>
<bean id="indexController" class="com.helloworld.controller.IndexController">
<property name="artistDao" ref="artistDao"/>
<property name="methodNameResolver">
<bean class="org.springframework.web.servlet.mvc.multiaction.PropertiesMethodNameResolver">
<property name="alwaysUseFullPath" value="true"/>
<property name="mappings">
<props>
<prop key="/HelloWorld.Web">getAllArtists</prop>
</props>
</property>
</bean>
</property>
</bean>
我正在使用 Spring 2.5.6 和 Bea Weblogic Server 9.2
这是我的 web.xml
<web-app id="WebApp_ID" version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
这是 IndexController
public class IndexController extends MultiActionController {
private ArtistDao artistsDao;
public ModelAndView getAllArtists(HttpServletRequest request, HttpServletResponse response) throws SQLException{
ModelAndView mav = new ModelAndView();
mav.setViewName("index");
List<Artist> artists = artistsDao.getAll();
mav.addObject("artists", artists);
return mav;
}
public void setArtistsDao(ArtistDao artistsDao) {
this.artistsDao = artistsDao;
}
}
I get this error whenever I try to view my tutorial app in the browser
WARNING: No mapping found for HTTP request with URI [/HelloWorld.Web] in DispatcherServlet with name 'dispatcher'
That just means the request is being received by the dispatcher servlet but it can't forward it to a controller.
But I can't seem to know where the problem is. I think I've mapped this correctly:
<bean id="urlMapping"
class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<props>
<prop key="/HelloWorld.Web">indexController</prop>
</props>
</property>
</bean>
<bean id="indexController" class="com.helloworld.controller.IndexController">
<property name="artistDao" ref="artistDao"/>
<property name="methodNameResolver">
<bean class="org.springframework.web.servlet.mvc.multiaction.PropertiesMethodNameResolver">
<property name="alwaysUseFullPath" value="true"/>
<property name="mappings">
<props>
<prop key="/HelloWorld.Web">getAllArtists</prop>
</props>
</property>
</bean>
</property>
</bean>
I am using Spring 2.5.6 and Bea Weblogic Server 9.2
Here's my web.xml
<web-app id="WebApp_ID" version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
Here's the IndexController
public class IndexController extends MultiActionController {
private ArtistDao artistsDao;
public ModelAndView getAllArtists(HttpServletRequest request, HttpServletResponse response) throws SQLException{
ModelAndView mav = new ModelAndView();
mav.setViewName("index");
List<Artist> artists = artistsDao.getAll();
mav.addObject("artists", artists);
return mav;
}
public void setArtistsDao(ArtistDao artistsDao) {
this.artistsDao = artistsDao;
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我对此不太确定,但我认为问题出在 web.xml 中的以下条目中:
Servlet 2.4 规范对于将请求映射到 servlet 来说是完全模糊的(IMO),上面的声明意味着“默认”servlet应用程序,在这种情况下,servlet 路径是请求 URI 减去上下文路径,并且路径信息为 null(无论这意味着什么)。
那么,如果将上面的内容替换为以下内容,会改变什么吗?
I'm not really sure about this but I think the problem is in the following entry in web.xml:
The Servlet 2.4 Specification is a total blur (IMO) regarding mapping requests to servlets and the above declaration means the "default" servlet of the application, in which case the servlet path is the request URI minus the context path and the path info is null (whatever the heck that means).
So, if you replace the above with the following, does it change anything?