勇敢的战斗 2019-04-25 19:40 采纳率: 0%
浏览 295

初学SSM遇见404错误,请大家帮忙找出问题

初学SSM框架的菜鸟,碰到了项目完成404的错误
具体代码和框架图如下,请各位大佬解惑图片说明
图片说明
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"
>  
<context-param>  
    <param-name>contextConfigLocation</param-name>  
<param-value>classpath:applicationContext.xml</param-value>  
      </context-param>  
<!-- 加载Spring容器配置 -->  
<listener>  
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>  
</listener>  

<!-- 配置SpringMVC核心控制器 -->



springmvc

org.springframework.web.servlet.DispatcherServlet

<!-- 配置初始配置化文件,前面contextConfigLocation看情况二选一 -->



contextConfigLocation

classpath:spring-config.xml

    <!-- 启动加载一次 -->    
    <load-on-startup>1</load-on-startup>  
</servlet>  

<!--为DispatcherServlet建立映射 -->  
<servlet-mapping>  
    <servlet-name>springmvc</servlet-name>  
    <!-- 此处可以可以配置成*.do,对应struts的后缀习惯 -->  
    <url-pattern>/</url-pattern>  
</servlet-mapping>  

<!-- 解决工程编码过滤器 -->



encoding

org.springframework.web.filter.CharacterEncodingFilter




encoding

UTF-8






encoding

*.action

Controller.java代码如下:
package com.itheima.controller;

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

import com.itheima.po.Customer;
import com.itheima.service.CustomerService;

@Controller
public class CustomerController {
@Autowired
private CustomerService customerService;

@RequestMapping("/findCustomerById")
public String findCustomerById(Integer id,Model model){
    Customer customer=customerService.findCustomerById(id);
    model.addAttribute("customer",customer);
    //返回客户信息展示页面
    return "customer";

}




页面错误显示:

}图片说明

  • 写回答

4条回答

  • 专家-郭老师 Java领域新星创作者 2019-04-25 20:24
    关注

    我不知道你首页是不是404,如果是这个页面404那就是路径设置不对了return "customer"; 不对了,也有可能配置文件问题

    评论

报告相同问题?

悬赏问题

  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥30 用arduino开发esp32控制ps2手柄一直报错
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥20 求一个html代码,有偿