0

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.SimpleUrlHandlerMapping">
  <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>
1
  • i think This code could be the problem <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> Commented Aug 30, 2010 at 19:47

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.