警告:在DispatcherServlet中没有找到具有URI [/projectdemo/WEB-INF/jsp/results.jsp]的HTTP请求的映射,名称为“dispatcher” [英] WARNING: No mapping found for HTTP request with URI [/projectdemo/WEB-INF/jsp/results.jsp] in DispatcherServlet with name 'dispatcher'

查看:301
本文介绍了警告:在DispatcherServlet中没有找到具有URI [/projectdemo/WEB-INF/jsp/results.jsp]的HTTP请求的映射,名称为“dispatcher”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这个问题已经重复了多次,但是我无法解决我的问题,看其他线程,仍然我的问题还没有解决?

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 ?

我正在使用eclipse-Spring和Tomcat服务器

I am using eclipse-Spring and Tomcat Server

我的web.xml为:

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> 

我的dispatcher-servlet.xml为:

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:

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>

我的LoginController为:

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文件:

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>

我在控制台中低于msg:

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'

我得到http:// localhost:8080 / projectdemo / Login.jsp

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

类型状态报告
消息描述
请求的资源()不可用。

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

在控制台中,返回LoginController的值并打印值,并使用mysql数据库用户表值检查

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

返回msg没有显示,在控制台中显示为:

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 !!!

推荐答案

您的返回消息

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

不是一个消息!它是一个模型(键消息:值消息)和视图(result)
视图是应该呈现的jsp文件的名称。而且你没有这样的一个jsp文件(这就是警告没有找到HTTP请求与URI的映射[/projectdemo/WEB-INF/jsp/results.jsp] 抱怨)

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)

您需要编写这个jsp文件并将其存储在 /WEB-INF/jsp/results.jsp

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

这篇关于警告:在DispatcherServlet中没有找到具有URI [/projectdemo/WEB-INF/jsp/results.jsp]的HTTP请求的映射,名称为“dispatcher”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆