大毛毛毛 2022-07-05 13:28 采纳率: 0%
浏览 262
已结题

eclipse通过SpringMVC运行login.jsp报错404

 用eclipse写web项目,写了一个index.html在网页中可以运行,但是后续写在WEB-INF中的login.jsp无法运行,报404错误
404错误:

img


项目目录

img

img

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" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
  <display-name>shopping06</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>
</web-app>

dispatcher-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:p="http://www.springframework.org/schema/p"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    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">
    <!-- 到哪些包下扫描controller -->
    <context:component-scan base-package="com.tedu.controller"></context:component-scan>
    <!-- 打开基于注解的操作 -->
    <mvc:annotation-driven>  </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>
     
     <!-- 全局异常处理 -->
     <bean class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
         <property name="exceptionMappings">
             <props>
                 <prop key="com.tedu.exception.UserException">error</prop>
             </props>
         </property>
     </bean>
     <!-- 设置了multipartResolver才能完成文件上传 -->
     <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
         <!-- 设置文件上传的大小 -->
         <property name="maxUploadSize" value="2000000"></property>
     </bean>
     <!-- SpringMVC访问静态文件 -->
     <mvc:resources location="/css/" mapping="/css/**"></mvc:resources>
     <mvc:resources location="/js/" mapping="/js/**"></mvc:resources>
     <mvc:resources location="/image/" mapping="/image/**"></mvc:resources>
     <mvc:resources location="/img/" mapping="/img/**"></mvc:resources>
     <mvc:resources location="/" mapping="/**"></mvc:resources>
</beans>

admincontroller.java:

package com.tedu.controller;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.tedu.model.Admin;
import com.tedu.service.AdminService;

@Controller
@RequestMapping("/admin")
public class AdminController {
 
 @Autowired
 private AdminService adminService;
 
 @RequestMapping(value="/login",method=RequestMethod.GET)
 public String login(){
  return "admin/login";
 }
 
 @RequestMapping(value="/login",method=RequestMethod.POST)
 public String login(String username,String password,HttpSession session){
  Admin admin = null;
  try {
   admin = adminService.login(username, password);
  } catch (Exception e) {
   e.printStackTrace();
  }
  return "redirect:main";
 }
 
 @RequestMapping(value="/login",method=RequestMethod.GET)
 public String logout(HttpSession session) {
  session.invalidate();
  return "redirect:/admin/login";
 }
 
 @RequestMapping(value="/main",method=RequestMethod.GET)
 public String main() {
  return "admin/main/main";
 }
 @RequestMapping(value="/top",method=RequestMethod.GET)
 public String top() {
  return "admin/main/top";
 }
 
 @RequestMapping(value="/left",method=RequestMethod.GET)
 public String left() {
  return "admin/main/left";
 }
 
 @RequestMapping(value="/welcome",method=RequestMethod.GET)
 public String welcome() {
  return "admin/main/welcome";
 }
 
 
 

 
}

控制台:
七月 05, 2022 12:48:46 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Server version: Apache Tomcat/8.5.34
七月 05, 2022 12:48:46 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Server built: Sep 4 2018 22:28:22 UTC
七月 05, 2022 12:48:46 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Server number: 8.5.34.0
七月 05, 2022 12:48:46 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: OS Name: Windows 10
七月 05, 2022 12:48:46 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: OS Version: 10.0
七月 05, 2022 12:48:46 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Architecture: amd64
七月 05, 2022 12:48:46 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Java Home: D:\jdk1.8.0_74\jre
七月 05, 2022 12:48:46 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: JVM Version: 1.8.0_74-b02
七月 05, 2022 12:48:46 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: JVM Vendor: Oracle Corporation
七月 05, 2022 12:48:46 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: CATALINA_BASE: D:\apache-tomcat-8.5.34
七月 05, 2022 12:48:46 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: CATALINA_HOME: D:\apache-tomcat-8.5.34
七月 05, 2022 12:48:46 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dcatalina.base=D:\apache-tomcat-8.5.34
七月 05, 2022 12:48:46 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dcatalina.home=D:\apache-tomcat-8.5.34
七月 05, 2022 12:48:46 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dwtp.deploy=D:\apache-tomcat-8.5.34\webapps
七月 05, 2022 12:48:46 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Djava.endorsed.dirs=D:\apache-tomcat-8.5.34\endorsed
七月 05, 2022 12:48:46 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dfile.encodin
七月 05, 2022 12:48:46 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Server version: Apache Tomcat/8.5.34
七月 05, 2022 12:48:46 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Server built: Sep 4 2018 22:28:22 UTC
七月 05, 2022 12:48:46 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Server number: 8.5.34.0
七月 05, 2022 12:48:46 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: OS Name: Windows 10
七月 05, 2022 12:48:46 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: OS Version: 10.0
七月 05, 2022 12:48:46 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Architecture: amd64
七月 05, 2022 12:48:46 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Java Home: D:\jdk1.8.0_74\jre
七月 05, 2022 12:48:46 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: JVM Version: 1.8.0_74-b02
七月 05, 2022 12:48:46 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: JVM Vendor: Oracle Corporation
七月 05, 2022 12:48:46 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: CATALINA_BASE: D:\apache-tomcat-8.5.34
七月 05, 2022 12:48:46 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: CATALINA_HOME: D:\apache-tomcat-8.5.34
七月 05, 2022 12:48:46 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dcatalina.base=D:\apache-tomcat-8.5.34
七月 05, 2022 12:48:46 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dcatalina.home=D:\apache-tomcat-8.5.34
七月 05, 2022 12:48:46 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dwtp.deploy=D:\apache-tomcat-8.5.34\webapps
七月 05, 2022 12:48:46 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Djava.endorsed.dirs=D:\apache-tomcat-8.5.34\endorsed
七月 05, 2022 12:48:46 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dfile.encoding=UTF-8
七月 05, 2022 12:48:46 下午 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: [D:\jdk1.8.0_74\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;D:/eclipse/jre/bin/server;D:/eclipse/jre/bin;D:/eclipse/jre/lib/amd64;D:\Oracle\app\oracle\product\10.2.0\server\bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Windows\System32\OpenSSH;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\System32\OpenSSH;D:\jdk1.8.0_74\bin;C:\Users\Doris\Desktop\2022寒假实训\maven\apache-maven-3.6.3\bin;C:\Users\Doris\Desktop\2022寒假实训\maven\apache-maven-3.6.3\bin;%MAVEN_HOME%\bin;C:\Users\Doris\AppData\Local\Microsoft\WindowsApps;C:\Users\Doris\IntelliJ IDEA 2021.2\bin;;D:\eclipse;;.]
七月 05, 2022 12:48:47 下午 org.apache.coyote.AbstractProtocol init
信息: Initializing ProtocolHandler ["http-nio-8080"]
七月 05, 2022 12:48:47 下午 org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
信息: Using a shared selector for servlet write/read
七月 05, 2022 12:48:47 下午 org.apache.coyote.AbstractProtocol init
信息: Initializing ProtocolHandler ["ajp-nio-8009"]
七月 05, 2022 12:48:47 下午 org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
信息: Using a shared selector for servlet write/read
七月 05, 2022 12:48:47 下午 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 895 ms
七月 05, 2022 12:48:47 下午 org.apache.catalina.core.StandardService startInternal
信息: Starting service [Catalina]
七月 05, 2022 12:48:47 下午 org.apache.catalina.core.StandardEngine startInternal
信息: Starting Servlet Engine: Apache Tomcat/8.5.34
七月 05, 2022 12:48:47 下午 org.apache.catalina.startup.HostConfig deployDescriptor
信息: Deploying configuration descriptor [D:\apache-tomcat-8.5.34\conf\Catalina\localhost\shopping06.xml]
七月 05, 2022 12:48:47 下午 org.apache.catalina.startup.HostConfig deployDescriptor
警告: A docBase [D:\apache-tomcat-8.5.34\webapps\shopping06] inside the host appBase has been specified, and will be ignored
七月 05, 2022 12:48:47 下午 org.apache.catalina.startup.SetContextPropertiesRule begin
警告: [SetContextPropertiesRule]{Context} Setting property 'source' to 'org.eclipse.jst.jee.server:shopping06' did not find a matching property.
七月 05, 2022 12:48:50 下午 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.
七月 05, 2022 12:48:51 下午 org.apache.catalina.core.ApplicationContext log
信息: No Spring WebApplicationInitializer types detected on classpath
七月 05, 2022 12:48:51 下午 org.apache.catalina.util.SessionIdGeneratorBase createSecureRandom
警告: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [524] milliseconds.
七月 05, 2022 12:48:51 下午 org.apache.catalina.startup.HostConfig deployDescriptor
信息: Deployment of configuration descriptor [D:\apache-tomcat-8.5.34\conf\Catalina\localhost\shopping06.xml] has finished in [4,399] ms
七月 05, 2022 12:48:51 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory [D:\apache-tomcat-8.5.34\webapps\ch1]
七月 05, 2022 12:48:51 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deployment of web application directory [D:\apache-tomcat-8.5.34\webapps\ch1] has finished in [24] ms
七月 05, 2022 12:48:51 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory [D:\apache-tomcat-8.5.34\webapps\docs]
七月 05, 2022 12:48:51 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deployment of web application directory [D:\apache-tomcat-8.5.34\webapps\docs] has finished in [45] ms
七月 05, 2022 12:48:51 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory [D:\apache-tomcat-8.5.34\webapps\examples]
七月 05, 2022 12:48:52 下午 org.apache.catalina.core.ApplicationContext log
信息: ContextListener: contextInitialized()
七月 05, 2022 12:48:52 下午 org.apache.catalina.core.ApplicationContext log
信息: SessionListener: contextInitialized()
七月 05, 2022 12:48:52 下午 org.apache.catalina.core.ApplicationContext log
信息: ContextListener: attributeAdded('StockTicker', 'async.Stockticker@7eb474f1')
七月 05, 2022 12:48:52 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deployment of web application directory [D:\apache-tomcat-8.5.34\webapps\examples] has finished in [473] ms
七月 05, 2022 12:48:52 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory [D:\apache-tomcat-8.5.34\webapps\host-manager]
七月 05, 2022 12:48:52 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deployment of web application directory [D:\apache-tomcat-8.5.34\webapps\host-manager] has finished in [39] ms
七月 05, 2022 12:48:52 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory [D:\apache-tomcat-8.5.34\webapps\manager]
七月 05, 2022 12:48:52 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deployment of web application directory [D:\apache-tomcat-8.5.34\webapps\manager] has finished in [46] ms
七月 05, 2022 12:48:52 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory [D:\apache-tomcat-8.5.34\webapps\ROOT]
七月 05, 2022 12:48:52 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deployment of web application directory [D:\apache-tomcat-8.5.34\webapps\ROOT] has finished in [27] ms
七月 05, 2022 12:48:52 下午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["http-nio-8080"]
七月 05, 2022 12:48:52 下午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["ajp-nio-8009"]
七月 05, 2022 12:48:52 下午 org.apache.catalina.startup.Catalina start
信息: Server startup in 5125 ms

  • 写回答

7条回答 默认 最新

  • CSDN专家-sinJack 2022-07-05 18:21
    关注

    请求有没有进接口,在接口中加点输出看看。

    评论

报告相同问题?

问题事件

  • 系统已结题 7月13日
  • 赞助了问题酬金10元 7月5日
  • 创建了问题 7月5日

悬赏问题

  • ¥20 求下下面这个数据结构代码
  • ¥15 路由器考试怎么办,有懂行的吗 ,eNSP
  • ¥20 前端 二进制文件流图片转化异常
  • ¥15 github上的这个C语言项目如何跑起来
  • ¥15 java 判断某个数 区间是否存在
  • ¥15 appium控制多个雷电模拟器问题
  • ¥15 C# iMobileDevice
  • ¥15 谁会做这个啊#ensp#Boson NetSim
  • ¥15 如何编写针对TPS6503320FRGE型号的电源管理芯片的编程代码?
  • ¥15 设计简单目录管理系统,要满足以下内容