0

jspログインページが1つしかない単純なsp [リングmvcを構築しようとしていますが、コンソールで次の警告が表示されるため、アプリケーションの実行時に表示できませんでした:

警告: 「SpringBlogger」という名前の DispatcherServlet で、URI [/SpringBlogger/WEB-INF/jsp/login.jsp] の HTTP 要求のマッピングが見つかりません

web.xml :

プレーンコピーをクリップボードプリントに表示しますか? 注: コード ブロック内のテキスト コンテンツは、自動的にワードラップされます。

<?xml version="1.0" encoding="UTF-8"?>  
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">  
  <display-name>SpringBlogger</display-name>  
  <welcome-file-list>  
    <welcome-file>login.jsp</welcome-file>  
  </welcome-file-list>  

  <servlet>  
<servlet-name>SpringBlogger</servlet-name>  
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>  
<load-on-startup>1</load-on-startup>  
</servlet>  
<servlet-mapping>  
<servlet-name>SpringBlogger</servlet-name>  
<url-pattern>*.jsp</url-pattern>  
</servlet-mapping>  
</web-app>  

SpringBlogger-servlet.xml

    <?xml version="1.0" encoding="UTF-8"?>  
<beans xmlns="http://www.springframework.org/schema/beans"  
xmlns:context="http://www.springframework.org/schema/context"  
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
xmlns:mvc="http://www.springframework.org/schema/mvc"  
xsi:schemaLocation="http://www.springframework.org/schema/mvc  
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd  
http://www.springframework.org/schema/beans  
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd  
http://www.springframework.org/schema/context   
http://www.springframework.org/schema/context/spring-context-3.0.xsd">  
<mvc:resources mapping="/resources/**" location="/resources/"/>  

<mvc:annotation-driven/>  
<context:component-scan base-package="com.beans" />  

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

HomeController.java:-

    package com.beans;  

import org.springframework.stereotype.Controller;  
import org.springframework.ui.ModelMap;  
import org.springframework.web.bind.annotation.RequestMapping;  

@Controller  
public class HomeController {  

    @RequestMapping("/login.jsp")  
    public String showHomePage(ModelMap map){  
        map.addAttribute("message", "Welcome to Spring Blogger");  
        return "login";  
    }  
}  

login.jsp :-

    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"  
    pageEncoding="ISO-8859-1"%>  
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>  
<!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>Insert title here</title>  
</head>  
<body>  
<form action="LoginAction" method="post">  
<h1>${message}</h1>  
<table>  
<tr>  
<td>UserName: </td>  
<td><form:input path="UserName"/>  
</td>  
</tr>  

<tr>  
    <td>Password: </td>  
    <td><form:password path="Password"/></td>  
</tr>  

<tr>  
    <td colspan="2">  
        <input type="submit" value="submit">  
    </td>  
</tr>  
</table>  
</form>  
</body>  
</html>  

この種の問題が他のスレッドで既に言及されていることは知っていますが、既に含まれているが同じエラーが発生しているため、問題が解決されていません。

私が欠けているものを教えてください。

ありがとう、マニッシュ

4

2 に答える 2

0

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"                     xmlns="http://java.sun.com/xml/ns/javaee"  xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee  http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID"  version="3.0">  
  <display-name>SpringBlogger</display-name>  
      <welcome-file-list>  
        <welcome-file>index.jsp</welcome-file>
      </welcome-file-list>  

<servlet>  
    <servlet-name>SpringBlogger</servlet-name>  
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>  
    <load-on-startup>1</load-on-startup>  
</servlet>  

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

SpringBlogger-servlet.xml

<?xml version="1.0" encoding="UTF-8"?>  
<beans xmlns="http://www.springframework.org/schema/beans"  
xmlns:context="http://www.springframework.org/schema/context"  
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
xmlns:mvc="http://www.springframework.org/schema/mvc"  
xsi:schemaLocation="http://www.springframework.org/schema/mvc  
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd  
http://www.springframework.org/schema/beans  
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd  
http://www.springframework.org/schema/context   
http://www.springframework.org/schema/context/spring-context-3.0.xsd">  
<mvc:resources mapping="/resources/**" location="/resources/"/>  

<mvc:annotation-driven/>  
<context:component-scan base-package="com.beans.*" />  

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

HomeController.java

package com.beans;  

import org.springframework.stereotype.Controller;  
import org.springframework.ui.ModelMap;  
import org.springframework.web.bind.annotation.RequestMapping;  

@Controller  
public class HomeController {  

    @RequestMapping(value="/login",method=RequestMethod.POST")  
    public String showHomePage(ModelMap map){  
        map.addAttribute("message", "Welcome to Spring Blogger");  
        return "login";  
    }  
}

login.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"  
    pageEncoding="ISO-8859-1"%>  
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>  
<!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>Insert title here</title>  
</head>  
<body>  
<form action="/login" method="post">  
<h1>${message}</h1>  
<table>  
<tr>  
<td>UserName: </td>  
<td><form:input path="UserName"/>  
</td>  
</tr>  

<tr>  
    <td>Password: </td>  
    <td><form:password path="Password"/></td>  
</tr>  

<tr>  
    <td colspan="2">  
        <input type="submit" value="submit">  
    </td>  
</tr>  
</table>  
</form>  
</body>  
</html>
于 2015-08-27T06:53:36.580 に答える