页面404是为什么,tomacat也没有报错

页面404是为什么,tomacat也没有报错

package com.imooc.sm.controller;

import com.imooc.sm.entity.Department;
import com.imooc.sm.service.DepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
@Controller("departmentController")
public class DepartmentController {
    @Autowired
    private DepartmentService departmentService;
    public void list(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        List<Department> list = departmentService.getAll();
        request.setAttribute("list",list);
        request.getRequestDispatcher("../department_list.jsp").forward(request,response);
    }
}
===============================================================================

[2019-07-20 04:55:09,601] Artifact sm_web:war exploded: Artifact is deployed successfully

[2019-07-20 04:55:09,601] Artifact sm_web:war exploded: Deploy took 3,807 milliseconds

20-Jul-2019 16:55:15.713 信息 [localhost-startStop-2] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [D:\tomcat and javaEE\apache-tomcat-8.5.41\webapps\docs]

20-Jul-2019 16:55:16.183 信息 [localhost-startStop-2] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [D:\tomcat and javaEE\apache-tomcat-8.5.41\webapps\docs] has finished in [335] ms

20-Jul-2019 16:55:16.184 信息 [localhost-startStop-2] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [D:\tomcat and javaEE\apache-tomcat-8.5.41\webapps\examples]

20-Jul-2019 16:55:21.332 信息 [localhost-startStop-2] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [D:\tomcat and javaEE\apache-tomcat-8.5.41\webapps\examples] has finished in [5,148] ms

20-Jul-2019 16:55:21.332 信息 [localhost-startStop-2] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [D:\tomcat and javaEE\apache-tomcat-8.5.41\webapps\host-manager]

20-Jul-2019 16:55:21.717 信息 [localhost-startStop-2] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [D:\tomcat and javaEE\apache-tomcat-8.5.41\webapps\host-manager] has finished in [385] ms

20-Jul-2019 16:55:21.717 信息 [localhost-startStop-2] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [D:\tomcat and javaEE\apache-tomcat-8.5.41\webapps\manager]

20-Jul-2019 16:55:21.797 信息 [localhost-startStop-2] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [D:\tomcat and javaEE\apache-tomcat-8.5.41\webapps\manager] has finished in [79] ms

20-Jul-2019 16:55:21.797 信息 [localhost-startStop-2] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [D:\tomcat and javaEE\apache-tomcat-8.5.41\webapps\mybatispro_war]

20-Jul-2019 16:55:21.888 信息 [localhost-startStop-2] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [D:\tomcat and javaEE\apache-tomcat-8.5.41\webapps\mybatispro_war] has finished in [91] ms

20-Jul-2019 16:55:21.888 信息 [localhost-startStop-2] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [D:\tomcat and javaEE\apache-tomcat-8.5.41\webapps\oa_web_war]

20-Jul-2019 16:55:32.058 信息 [localhost-startStop-2] 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.

20-Jul-2019 16:55:32.563 信息 [localhost-startStop-2] org.springframework.web.servlet.FrameworkServlet.initServletBean Initializing Servlet 'springMVC'

20-Jul-2019 16:55:36.506 信息 [localhost-startStop-2] org.springframework.web.servlet.FrameworkServlet.initServletBean Completed initialization in 3943 ms

20-Jul-2019 16:55:36.513 信息 [localhost-startStop-2] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [D:\tomcat and javaEE\apache-tomcat-8.5.41\webapps\oa_web_war] has finished in [14,625] ms

20-Jul-2019 16:55:36.513 信息 [localhost-startStop-2] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [D:\tomcat and javaEE\apache-tomcat-8.5.41\webapps\ROOT]

20-Jul-2019 16:55:36.558 信息 [localhost-startStop-2] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [D:\tomcat and javaEE\apache-tomcat-8.5.41\webapps\ROOT] has finished in [45] ms

20-Jul-2019 16:55:36.558 信息 [localhost-startStop-2] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [D:\tomcat and javaEE\apache-tomcat-8.5.41\webapps\rumenchengxu_war]

20-Jul-2019 16:55:38.732 信息 [localhost-startStop-2] 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.

20-Jul-2019 16:55:39.107 信息 [localhost-startStop-2] org.springframework.web.servlet.FrameworkServlet.initServletBean Initializing Servlet 'dispatcherServlet'

20-Jul-2019 16:55:40.383 信息 [localhost-startStop-2] org.springframework.web.servlet.FrameworkServlet.initServletBean Completed initialization in 1276 ms

20-Jul-2019 16:55:40.398 信息 [localhost-startStop-2] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [D:\tomcat and javaEE\apache-tomcat-8.5.41\webapps\rumenchengxu_war] has finished in [3,840] ms

=================================================================

<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2019/7/20
  Time: 15:42
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>部门列表</title>
    <link rel="stylesheet" type="text/css" href="../css/reset.css"/>
    <link rel="stylesheet" type="text/css" href="../css/common.css"/>
    <link rel="stylesheet" type="text/css" href="../css/thems.css">
    <script type="text/javascript" src="../js/jquery-1.8.3.min.js"></script>
    <script type="text/javascript">
        $(function(){
            //自适应屏幕宽度
            window.onresize=function(){ location=location };

            var main_h = $(window).height();
            $('.hy_list').css('height',main_h-45+'px');

            var search_w = $(window).width()-40;
            $('.search').css('width',search_w+'px');
            //$('.list_hy').css('width',search_w+'px');
        });
    </script>
    <!--框架高度设置-->
</head>

<body onLoad="Resize();">
<div id="right_ctn">
    <div class="right_m">
        <div class="hy_list">
            <div class="box_t">
                <span class="name">部门列表</span>
            </div>
            <div class="space_hx">&nbsp;</div>
            <!--列表-->
            <table cellpadding="0" cellspacing="0" class="list_hy">
                <tr>
                    <th class="xz" scope="col">选择</th>
                    <th scope="col">名称</th>
                    <th scope="col">地址</th>
                    <th scope="col">操作</th>
                </tr>
                <c:forEach items="list" var="dep">
                <tr>
                    <td class="xz"><input name="" type="checkbox" value=""></td>
                    <td>${dep.name}</td>
                    <td>${dep.address}</td>
                    <td>
                        <a href="add.html" class="btn">编辑</a>
                        <a href="" class="btn">删除</a>
                        <a href="detail.html" class="btn">查看</a>
                    </td>
                </tr>
                </c:forEach>

            </table>
            <!--列表-->
            <!--右边底部-->
            <div class="r_foot">
                <div class="r_foot_m">
                    <a href="add.html" class="btn">添加</a>
                </div>
            </div>
            <!--右边底部-->
        </div>
        <!--会议列表-->
    </div>
</div>
</body>
</html>


正在回答 回答被采纳积分+1

登陆购买课程后可参与讨论,去登陆

7回答
好帮手慕柯南 2019-07-22 16:36:07

同学你好!


  1.   同学修改之后是否有重启项目

  2. 方法没有访问,同学访问的地址时候是什么呢?

  3. 同学检查一下DispatcherServlet中的代码是否有误
    http://img1.sycdn.imooc.com//climg/5d35755d0001049f11460915.jpg

如果我回答解决了你的疑惑,请采纳,祝学习愉快~


提问者 qq_慕前端8123077 2019-07-22 15:25:30
好帮手慕柯南 2019-07-22 14:45:27

同学你好!

1.同学控制台不是list吗?同学访问list.do是不可以的

http://img1.sycdn.imooc.com//climg/5d355b540001d58405050147.jpg

2.同学的另一个问题老师已经回复了,https://class.imooc.com/course/qadetail/136668 同学可以看一下。

如果我的回答解决了你的疑惑,请采纳,祝学习愉快~

  • 提问者 qq_慕前端8123077 #1
    老师,是Controler这个控制器的方法没有执行,我在这个方法里面输出了一句话,控制台根本就没有输出
    2019-07-22 15:24:25
提问者 qq_慕前端8123077 2019-07-22 11:31:45
好帮手慕柯南 2019-07-22 10:05:44

同学你好!

是在idea的控制台可以输出吗?

如果是:

  1. 同学检查一下页面的目录,是否与老师的一样

    http://img1.sycdn.imooc.com//climg/5d35196d000157c404220758.jpg

  2. 同学在页面输出list时没有获取list有误,在items中需要以el表达式的形式获取。

    http://img1.sycdn.imooc.com//climg/5d3519a10001e87308090237.jpg

如果我的回答解决了你的疑惑,请采纳,祝学习愉快~

  • 提问者 qq_慕前端8123077 #1
    我看着是和老师的都一样的呀,但是就是没有反应,我在本课程的最后一节的OA系统案例也遇到了同样的问题,就是控制器里面的方法没反应,详见https://class.imooc.com/course/qadetail/136668 希望老师帮我看看
    2019-07-22 11:35:38
好帮手慕阿莹 2019-07-20 17:51:45

同学你好,报错404是找不到指定的文件资源,有可能是没有找到list 方法,也有可能是从list方法中没有找到 department_list.jsp  这个页面,

1、在这个list方法中输出一下,看看是否有访问到。

2、检查一下你的 department_list.jsp 是否存在,路径是否正确。

3、这个问题同学可以忽略,不影响程序的运行,这个只是这个图标赵不到了。

http://img1.sycdn.imooc.com//climg/5d32e3f80001238410420053.jpg


如果我的回答解决了你的疑惑,请采纳!祝学习愉快!


  • 提问者 qq_慕前端8123077 #1
    我按照老师给的方法测试了下,在list方法中输出了一句话,但是控制台中没有输出,为什么list方法不执行呢
    2019-07-22 09:14:19
提问者 qq_慕前端8123077 2019-07-20 17:12:37
问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
SSM主流框架入门与综合项目实战2018版
  • 参与学习           人
  • 提交作业       205    份
  • 解答问题       4317    个

Java中非常实用的SSM整合开发内容,从Spring开始,到MyBaits的进阶内容,再到SpringMVC的应用,最后是SSM整合开发案例,逐步深入,助你成长为一名Java工程师!

了解课程
请稍等 ...
意见反馈 帮助中心 APP下载
官方微信

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师