1

我正在用 Mybatis+Spring 3+Tomcat+Eclipse Indigo 做示例 Spring mvc 我遇到了这个问题 怎么了?任何关于成功运行这个项目的建议。以前的问题很清楚并运行此错误消息

  org.springframework.web.servlet.DispatcherServlet noHandlerFound
WARNING: No mapping found for HTTP request with URI [/SpringMVC/] in DispatcherServlet with name 'spring'

我的 web.xml 在这里

 <servlet>
    <servlet-name>spring</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>
                    /WEB-INF/servlet.xml
                    /WEB-INF/app.xml
            </param-value>
    </init-param>
  </servlet>

  <servlet-mapping>
    <servlet-name>spring</servlet-name>
    <url-pattern>/</url-pattern>
  </servlet-mapping>
</web-app>

我的 servlet.xml 是

    <context:annotation-config />
    <context:component-scan base-package="logen.board.controller" />    

   <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="viewClass" value="org.springframework.web.servlet.view.JstlView" />
        <property name="prefix" value="/jsp/" />
        <property name="suffix" value=".jsp" />
   </bean>

app.xml 在这里

<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
      <property name="dataSource" ref="dataSource" />
      <property name="mapperLocations" value="classpath:logen/board/dao/BoardDao.xml" />
</bean>

<bean id="sqlSession" class="org.mybatis.spring.SqlSessionTemplate">
    <constructor-arg index="0" ref="sqlSessionFactory" />
</bean> 

<bean id="BoardDao" class="logen.board.entity.BoardEntity"></bean>

和我的控制器

@Controller
public class Boardcontroller {
    @Autowired
    private SqlSession sql;
    @Autowired
    private BoardEntity bn;
    @RequestMapping("/list.do")
    private ModelAndView list(){
        BoardDao dao = sql.getMapper(BoardDao.class);
        ModelAndView mv = new ModelAndView();
        mv.setViewName("jsp/index");
        mv.addObject("list", dao.getList());
        return mv;
    }
}
4

0 回答 0