weixin_42292234
勇敢的战斗
2019-04-25 19:40

初学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条回答