每当我尝试在浏览器中查看我的教程应用程序时,我都会收到此错误
警告:在名称为“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>
这是索引控制器
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;
}
}