1

I know this question has been repeated multiple times, but I could not solve my problem looking at other threads , still my issue is not fixed ?

I am using eclipse-Spring and Tomcat Server

my web.xml as:

    <servlet-name>dispatcher</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
    <servlet-name>dispatcher</servlet-name>
    <url-pattern>*.jsp</url-pattern>
    </servlet-mapping>
    <context-param>
      <param-name>applicationContext</param-name>
      <param-value>applicationContext.xml</param-value>
    </context-param> 

My dispatcher-servlet.xml as:

    <context:component-scan base-package="com.test.controller"></context:component-scan> 
    <mvc:annotation-driven />
    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="prefix" value="/WEB-INF/jsp/"></property>
    <property name="suffix" value=".jsp"></property>
    </bean> </i>

applicationContext.xml as:

    <bean id="dataSourceBean" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    <property name="driverClassName" value="com.mysql.jdbc.Driver"></property>
    <property name="url" value="jdbc:mysql://localhost/projectdemo"></property>
    <property name="username" value="root"></property>
    <property name="password" value="mysql"></property>        
    </bean> 
    <bean id="sessionFactoryBean" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <property name="dataSource" ref="dataSourceBean"></property>
    <property name="mappingResources">
        <value>com/test/pojo/User.hbm.xml</value>                   
    </property>
    <property name="hibernateProperties">
          <props>
              <prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
              <prop key="hibernate.show_sql">true</prop>
          </props>
     </property>
    </bean>
    <bean id="hibernateTemplateBean" class="org.springframework.orm.hibernate3.HibernateTemplate">
    <property name="sessionFactory" ref="sessionFactoryBean"></property>
</bean>
     <bean id="authenticateServiceBean" class="com.test.service.AuthticateService">
    <property name="hibernateTemplate" ref="hibernateTemplateBean"></property>
    </bean>

my LoginController as:

    @RequestMapping("/Login.jsp")
    public class LoginController {
    @Autowired 
 private AuthticateService authenticateService;
 //@RequestMapping(value ="WEB-INF/jsp/results.jsp",method = RequestMethod.POST)
 @RequestMapping(method = RequestMethod.POST)
 public ModelAndView processCredentials(@RequestParam("username")String username,@RequestParam("password")String password) {
     System.out.println ("in LoginController");
     String message = "Invalid credentials";
     if(authenticateService.verifyUserNameAndPassword(username, password)) {
         System.out.println ("after IFin LoginController");
         message = "Welcome " + username + "!!";
         System.out.println ("after IFin LoginControllermsg" +message);
     }

     ModelAndView msg = new ModelAndView();
     msg.setViewName("results");
     msg.addObject("message",message);
     System.out.println ("before return" +message);
     return msg;
    //return new ModelAndView("results","message",message);
    }
     }

results.jsp file:

    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01  Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>ProjectDemo</title>
    </head>
    <body>
    <h1><%= request.getAttribute("message") %></h1>
    </body>
    </html>

I am getting below msg in console:

    userobject
    User ID : 1, User name : admin, Password : admin123
    after IFin LoginController
    after IFin LoginControllermsgWelcome admin!!
    before returnWelcome admin!!
    Nov 23, 2012 11:19:08 AM org.springframework.web.servlet.DispatcherServlet   noHandlerFound
    WARNING: No mapping found for HTTP request with URI [/projectdemo/WEB- INF/jsp/results.jsp] in DispatcherServlet with name 'dispatcher'

I am getting "http://localhost:8080/projectdemo/Login.jsp"

HTTP Status 404 -

type Status report message description The requested resource () is not available.

In the console it is returning values from LoginController and printing the values and getting checked with the mysql database user table values.

The "return msg" is not getting displayed which is showing in console as :

    Nov 23, 2012 11:19:08 AM org.springframework.web.servlet.DispatcherServlet noHandlerFound
    WARNING: No mapping found for HTTP request with URI [/projectdemo/WEB-INF/jsp/results.jsp] in DispatcherServlet with name 'dispatcher'

Please can anyone help me out in this? It has been more than two days struck with it !!!

LeenaLatesh
  • 169
  • 1
  • 3
  • 12
  • exact duplicate of http://stackoverflow.com/questions/1266303/no-mapping-found-for-http-request-with-uri-web-inf-pages-apiform-jsp – Boris Treukhov Nov 23 '12 at 08:23
  • Thanks Boris !!! Issue fixed. I tried changing the in web.xml as dispatcher *.spring I tried changing into different extension(.spring) it worked !! – LeenaLatesh Nov 24 '12 at 04:36

1 Answers1

0

Your "return message"

 ModelAndView msg = new ModelAndView();
 msg.setViewName("results");
 msg.addObject("message",message);
 System.out.println ("before return" +message);
 return msg;

is not a message! It is a model (key "message": value message) and a view ("result") The view is the name of an jsp file that should be rendered. And you do not have such an jsp file (that is what the Warning No mapping found for HTTP request with URI [/projectdemo/WEB-INF/jsp/results.jsp] complains)

You need to write this jsp file and store it in /WEB-INF/jsp/results.jsp!

Ralph
  • 118,862
  • 56
  • 287
  • 383
  • Thanks Ralph for the response !! Well I already have jsp in /WEB-INF/jsp/results.jsp – LeenaLatesh Nov 23 '12 at 07:29
  • 1
    When i run the server using Tomcat, "http://localhost:8080/projectdemo/" link popup with loginname and password which is in index.html , when i submit the login and password , http 404 error appears. it is parsing through the controller and retrieving the username and password from mysql (pojo --> User.java & User.hbmn.xml). donno whats the issue even though I have results.jsp file !! – LeenaLatesh Nov 23 '12 at 07:41