势必拿下SpringBoot 2021-12-07 22:05 采纳率: 100%
浏览 26
已结题

SSM404 jsp页面请求未能进入控制类

我是刚学习SSM的学生,希望各位可以帮我看一下到底是哪一步出错了导致我的jsp无法进入到
@RequestMapping("/register.do")的这个方法中
首先是console的报错信息


十二月 07, 2021 9:56:56 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Server version:        Apache Tomcat/8.5.13
十二月 07, 2021 9:56:56 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Server built:          Mar 27 2017 14:25:04 UTC
十二月 07, 2021 9:56:56 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Server number:         8.5.13.0
十二月 07, 2021 9:56:56 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: OS Name:               Windows 10
十二月 07, 2021 9:56:56 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: OS Version:            10.0
十二月 07, 2021 9:56:56 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Architecture:          x86
十二月 07, 2021 9:56:56 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Java Home:             C:\Program Files (x86)\Java\jdk1.8.0_191\jre
十二月 07, 2021 9:56:56 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: JVM Version:           1.8.0_191-b12
十二月 07, 2021 9:56:56 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: JVM Vendor:            Oracle Corporation
十二月 07, 2021 9:56:56 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: CATALINA_BASE:         D:\Java\.metadata\.plugins\org.eclipse.wst.server.core\tmp0
十二月 07, 2021 9:56:56 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: CATALINA_HOME:         C:\Program Files (x86)\Java\apache-tomcat-8.5.13
十二月 07, 2021 9:56:56 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dcatalina.base=D:\Java\.metadata\.plugins\org.eclipse.wst.server.core\tmp0
十二月 07, 2021 9:56:56 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dcatalina.home=C:\Program Files (x86)\Java\apache-tomcat-8.5.13
十二月 07, 2021 9:56:56 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dwtp.deploy=D:\Java\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps
十二月 07, 2021 9:56:56 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Djava.endorsed.dirs=C:\Program Files (x86)\Java\apache-tomcat-8.5.13\endorsed
十二月 07, 2021 9:56:56 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dfile.encoding=UTF-8
十二月 07, 2021 9:56:56 下午 org.apache.catalina.core.AprLifecycleListener lifecycleEvent
信息: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files (x86)\Java\jdk1.8.0_191\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:/Program Files (x86)/Java/jdk1.8.0_191/bin/../jre/bin/client;C:/Program Files (x86)/Java/jdk1.8.0_191/bin/../jre/bin;C:/Program Files (x86)/Java/jdk1.8.0_191/bin/../jre/lib/i386;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;";C:\Program Files (x86)\Java\jdk1.8.0_191\bin;C:\Program Files (x86)\Java\jdk1.8.0_191\jre\bin;C:\Program Files (x86)\Java\jdk1.8.0_191\bin;C:\Program Files\dotnet\;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;D:\Visual(web)\Microsoft VS Code\bin;D:\Rose\common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Users\Administrator\AppData\Local\Microsoft\WindowsApps;;D:\新建文件夹 (2)\IntelliJ IDEA 2020.1\bin;;C:\Program Files (x86)\Java\eclipse;;.
十二月 07, 2021 9:56:56 下午 org.apache.coyote.AbstractProtocol init
信息: Initializing ProtocolHandler ["http-nio-8080"]
十二月 07, 2021 9:56:56 下午 org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
信息: Using a shared selector for servlet write/read
十二月 07, 2021 9:56:56 下午 org.apache.coyote.AbstractProtocol init
信息: Initializing ProtocolHandler ["ajp-nio-8009"]
十二月 07, 2021 9:56:56 下午 org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
信息: Using a shared selector for servlet write/read
十二月 07, 2021 9:56:56 下午 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 608 ms
十二月 07, 2021 9:56:56 下午 org.apache.catalina.core.StandardService startInternal
信息: Starting service Catalina
十二月 07, 2021 9:56:56 下午 org.apache.catalina.core.StandardEngine startInternal
信息: Starting Servlet Engine: Apache Tomcat/8.5.13
十二月 07, 2021 9:56:58 下午 org.apache.jasper.servlet.TldScanner scanJars
信息: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
十二月 07, 2021 9:56:58 下午 org.apache.catalina.startup.HostConfig deployDescriptor
信息: Deploying configuration descriptor D:\Java\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\conf\Catalina\localhost\Shopping3.0.xml
十二月 07, 2021 9:56:58 下午 org.apache.catalina.startup.SetContextPropertiesRule begin
警告: [SetContextPropertiesRule]{Context} Setting property 'source' to 'org.eclipse.jst.jee.server:Shopping3.0' did not find a matching property.
十二月 07, 2021 9:57:00 下午 org.apache.jasper.servlet.TldScanner scanJars
信息: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
十二月 07, 2021 9:57:00 下午 org.apache.catalina.core.ApplicationContext log
信息: No Spring WebApplicationInitializer types detected on classpath
十二月 07, 2021 9:57:00 下午 org.apache.catalina.core.ApplicationContext log
信息: Initializing Spring root WebApplicationContext
log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
十二月 07, 2021 9:57:01 下午 org.apache.catalina.core.ApplicationContext log
信息: Initializing Spring FrameworkServlet 'springDispatcherServlet'
十二月 07, 2021 9:57:01 下午 org.apache.catalina.startup.HostConfig deployDescriptor
信息: Deployment of configuration descriptor D:\Java\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\conf\Catalina\localhost\Shopping3.0.xml has finished in 3,217 ms
十二月 07, 2021 9:57:01 下午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["http-nio-8080"]
十二月 07, 2021 9:57:01 下午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["ajp-nio-8009"]
十二月 07, 2021 9:57:01 下午 org.apache.catalina.startup.Catalina start
信息: Server startup in 5459 ms

这是我的项目的目录文件

img


这是我的index.jsp


<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!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="${pageContext.request.contextPath}/register.do" method="post">
          姓名:<input type="text" name="phone"/><br>
          密码:<input type="text" name="password"/><br>
          <input type="submit" value="注册" /> 
          
         
</form>
</body>
</html>

然后是我的控制类handlers/VipController.java

package handlers;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

import Service.VipService;
import beans.Vip;

@RequestMapping("/index")
public class VipController  {
    @Autowired
    @Qualifier("vipService")
    private VipService service;
    
    

    public void setService(VipService service) {
        this.service = service;
    }



    @RequestMapping("/register.do")
    public String doRegister(int phone, String password) throws Exception {    
        /*Vip vip=new Vip(phone,password);
         service.addVip(vip);  */    
        System.out.println("111");
         return "/test/welcome.jsp";
         }

}

web.xml


<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
  <display-name>Shopping3.0</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
  
  
  
   <!-- 指定Spring配置文件的位置及名称 -->
  <context-param>
                  <param-name>contextConfigLocation</param-name>
                  <param-value>classpath:applicationContext-*.xml</param-value> 
  </context-param>
  <!-- 注册ServletContext监听器 -->
  <listener>
             <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>
  
 
   <!-- 编码过滤器 -->  
    <filter>  
        <filter-name>encodingFilter</filter-name>  
        <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>  
        <async-supported>true</async-supported>  
        <init-param>  
            <param-name>encoding</param-name>  
            <param-value>UTF-8</param-value>  
        </init-param>  
    </filter>  
    <filter-mapping>  
        <filter-name>encodingFilter</filter-name>  
        <url-pattern>/*</url-pattern>  
    </filter-mapping>  

  
  <!-- 整合SpringMVC的中央调度器 -->
  <servlet>
  <!-- Dispatcher是前端控制器,用于接受所有请求 -->
             <servlet-name>springDispatcherServlet</servlet-name>
             <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> 
     <!--  springmvc.xml文件如果在WEB-INF目录下,则不需要指明下面的init-param元素;
                  如果放在其他位置,需要用到下面的init-param元素来配置位置。 -->
     <init-param>
                  <param-name>contextConfigLocation</param-name>
                  <param-value>classpath:resources/springmvc-servlet.xml</param-value>
     </init-param>
     <!-- 容器启动即可加载servlet -->
     <load-on-startup>1</load-on-startup>
    
  </servlet>
  <!-- Mapper是一个衍生自HTTP规则并实现了servlet API映射规则的类”。 -->
   <servlet-mapping>
                    <servlet-name>springDispatcherServlet</servlet-name>
                    <url-pattern>/</url-pattern>
     </servlet-mapping>
     
     
  
 
</web-app>

applicationContext-mybatis.xml

<?xml version="1.0" encoding="UTF-8"?>  
<beans xmlns="http://www.springframework.org/schema/beans"  
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
        xmlns:aop="http://www.springframework.org/schema/aop"  
        xmlns:p="http://www.springframework.org/schema/p"  
        xmlns:tx="http://www.springframework.org/schema/tx"  
        xmlns:context="http://www.springframework.org/schema/context"  
        xsi:schemaLocation="   
            http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd   
            http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd   
            http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd 
            http://www.springframework.org/schema/context 
            http://www.springframework.org/schema/context/spring-context.xsd">  
            
 
    
    <!-- 读取数据库配置文件 -->
    <context:property-placeholder location="classpath:database.properties"/>
    
    <!-- JNDI获取数据源(使用dbcp连接池) -->  
    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close" scope="singleton">
            <property name="driverClassName" value="${driver}" />  
            <property name="url" value="${url}" />  
            <property name="username" value="${user}" />  
            <property name="password" value="${password}" />
            <property name="initialSize" value="${initialSize}"/>
            <property name="maxActive" value="${maxActive}"/>
            <property name="maxIdle" value="${maxIdle}"/>
            <property name="minIdle" value="${minIdle}"/>
            <property name="maxWait" value="${maxWait}"/>
            <property name="removeAbandonedTimeout" value="${removeAbandonedTimeout}"/>
            <property name="removeAbandoned" value="${removeAbandoned}"/>
            <!-- sql 心跳 -->
            <property name= "testWhileIdle" value="true"/>
            <property name= "testOnBorrow" value="false"/>
            <property name= "testOnReturn" value="false"/>
            <property name= "validationQuery" value="select 1"/>
            <property name= "timeBetweenEvictionRunsMillis" value="60000"/>
            <property name= "numTestsPerEvictionRun" value="${maxActive}"/>
    </bean>
    
 
       
       <!-- 配置mybitas SqlSessionFactoryBean-->
    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
        <property name="dataSource" ref="dataSource"/>
        <property name="configLocation" value="classpath:mybatis-config.xml"/>
    </bean>
    
    <context:component-scan base-package="dao"/>  
    <!-- 生成dao的代理对象 -->
        <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">  
         <property name="basePackage" value="dao" />  
    </bean>
     
    
           
      <!--注册组件扫描器  -->
            <context:component-scan base-package="handlers"></context:component-scan>
     <!-- 注册组件扫描器,注意:不能与SpringMVC的组件扫描器组合 -->
            <context:component-scan base-package="Service"></context:component-scan>
            <!-- 因为还没有dao的实现类所以扫service就可以了 -->
       
      <!-- 注册事务管理器 -->
      <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
            <property name="dataSource" ref="dataSource"></property>
      </bean>
      <!-- 注册事务注解驱动 -->
      <tx:annotation-driven transaction-manager="transactionManager"/>
      
      
   
    </beans>


springmvc-servlet.xml


<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:p="http://www.springframework.org/schema/p"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="
        http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context.xsd
        http://www.springframework.org/schema/mvc
        http://www.springframework.org/schema/mvc/spring-mvc.xsd">
        
    <context:component-scan base-package="handlers"/>
    
    <mvc:annotation-driven>
         <mvc:message-converters>
             <bean class="org.springframework.http.converter.StringHttpMessageConverter">
                 <property name="supportedMediaTypes">
                     <list>
                         <value>application/json;charset=UTF-8</value>
                     </list>
                 </property>
             </bean> 
             <bean class="com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter">
                 <property name="supportedMediaTypes">
                     <list>
                         <value>text/html;charset=UTF-8</value>
                         <value>application/json</value>
                     </list>
                 </property>
                 <property name="features">
                     <list>
                      <!--   Date的日期转换器 -->
                      <value>WriteDateUseDateFormat</value>
                    </list>
                </property>
            </bean>
        </mvc:message-converters>
    </mvc:annotation-driven>
    
    <mvc:resources location="/statics/" mapping="/statics/**"></mvc:resources>
    
    <!-- 配置多视图解析器:允许同样的内容数据呈现不同的view -->
    <bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
        <property name="favorParameter" value="true"/>
        <property name="defaultContentType" value="text/html"/>
        <property name="mediaTypes">
            <map>
                <entry key="html" value="text/html;charset=UTF-8"/>
                <entry key="json" value="application/json;charset=UTF-8"/>
                <entry key="xml" value="application/xml;charset=UTF-8"/>
            </map>
        </property>
        <property name="viewResolvers">
            <list>
                <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver" >
                    <property name="prefix" value="/WEB-INF/jsp/"/>
                    <property name="suffix" value=".jsp"/>
                </bean>        
            </list>
        </property>
    </bean>
      

    
    
    
</beans>   

谢谢!

  • 写回答

2条回答 默认 最新

  • 魂兮呀 2021-12-07 22:32
    关注

    注解没加

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 12月17日
  • 已采纳回答 12月9日
  • 创建了问题 12月7日

悬赏问题

  • ¥15 用C语言完成一个复杂的游戏
  • ¥15 如何批量更改很多个文件夹里的文件名中包含文件夹名?
  • ¥50 MTK手机模拟HID鼠标出现卡顿
  • ¥20 求下下面这个数据结构代码
  • ¥20 前端 二进制文件流图片转化异常
  • ¥15 github上的这个C语言项目如何跑起来
  • ¥15 java 判断某个数 区间是否存在
  • ¥15 appium控制多个雷电模拟器问题
  • ¥15 C# iMobileDevice
  • ¥15 谁会做这个啊#ensp#Boson NetSim