开发者

Problem with model, view and controller

I do a hello world very easy, now I want to catch data of a class and I can't do it, when I compile the project all perfect and when I run the project show me a error: Estado HTTP 404, and I don´t know how to fix the problem, help please.

my controller is welcomeController

public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
  throws ServletException, IOException {
   List usuarios = catalogFacadeImpl.getUserList();
   logger.info("Returning hello view with " + usuarios);
   return new ModelAndView("welcome", "usuarios", usuarios);

my model is branch_try_htmlModulo-servlet.xml

<bean name="/welcome.htm" class="com.bamboo.catW3.business.impl.WelcomeController"/>
<bean id="urlMapping" class="org.springframework.web.servlet.handler.S开发者_如何学PythonimpleUrlHandlerMapping">
  <property name="mappings">
        <props>
             <prop key="/welcome.htm">branch_try_htmlModulo</prop>
        </props>
    </property>
</bean>

<bean id="beerListController" class="com.bamboo.catW3.business.impl.WelcomeController">
    <property name="catalogFacadeImpl" ref="catalogFacadeTarget"/>
</bean>

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

my view is welcome.jsp

<html>
  <head><title>Hello :: Spring Application</title></head>
    <body>
     <table border="0">
       <c:forEach items="${usuarios}" var="usuario">
        <tr>
             <td><c:out value="${usuario.user_name}"/></td>
        </tr>
         </c:forEach>
    </table>
   </body>
</html> 

and my web.xml is

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>

<listener>
    <listener-class> org.springframework.web.context.ContextLoaderListener
    </listener-class>
</listener>

 <servlet>
    <servlet-name>branch_try_htmlModulo</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet
    </servlet-class>
    <load-on-startup>2</load-on-startup>
</servlet>

  <servlet-mapping>
    <servlet-name>branch_try_htmlModulo</servlet-name>
    <url-pattern>*.htm</url-pattern>
  </servlet-mapping>

  <welcome-file-list>
    <welcome-file>
      index.jsp
    </welcome-file>
  </welcome-file-list>


The entire Controller class hierarchy is deprecated. The preferred usage of Spring MVC is to use @Controller-annotated classes.

Before you go too far down this road, you might want to read this example.


try changing your config to this and report if you are still having the issue...

<bean id="welcomeController" class="com.bamboo.catW3.business.impl.WelcomeController"/>
<bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
  <property name="mappings">
        <props>
             <prop key="/welcome.htm">welcomeController</prop>
        </props>
    </property>
</bean>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜