No mapping found for HTTP request with URI

本文记录了一次在SpringMVC项目中遇到的NomappingfoundforHTTPrequestwithURI异常经历,作者通过检查代码,发现是@RequestMapping注解拼写错误导致。纠正后,系统恢复正常运行,提醒新手开发者注意此类细节。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

No mapping found for HTTP request with URI

controller:

package com.czxy.controller;

import com.czxy.domain.Dept;
import com.czxy.domain.Emp;
import com.czxy.domain.EmpVo;
import com.czxy.service.DeptService;
import com.czxy.service.EmpService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.portlet.bind.annotation.ResourceMapping;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@Controller
public class EmpController {
    @Resource
    private EmpService empService;

    @Resource
    private DeptService deptService;



    @ResourceMapping("/findAll")
    public String findAll(Model model){
        List<Emp> all = empService.findAll();

        List<EmpVo> list = new ArrayList<>();

        for (Emp emp : all) {
            list.add(new EmpVo(emp,deptService.findByDeptno(emp.getDeptno()).getDname()));
        }
        model.addAttribute("list",list);
        return "/emplist.jsp";
    }

    @RequestMapping("/insert")
    public String insert(Emp emp){
        empService.insert(emp);
        return "redirect:findAll.action";
    }

    @RequestMapping("/delete")
    public String delete(int empno){
        empService.deleteUserById(empno);
        return "redirect:findAll.action";
    }

    @RequestMapping("/findByEmpno")
    public String findByEmpno(int empno,Model model){
        Emp emp = empService.findByEmpno(empno);
        List<Dept> list = deptService.findAll();
        model.addAttribute("emp",emp);
        model.addAttribute("list",list);
        return "/updateemp.jsp";
    }

    @RequestMapping("/edit")
    public String edit(Emp emp){
        empService.edit(emp);
        return "redirect:findAll.action";
    }

}

今天下午出了这个异常找了好久也没有找到是哪里的问题,也查了挺多的,最后发现是自己单词写错了
希望新入坑的小伙伴不要像我一样 哈哈哈哈。

在这里插入图片描述

应该是@RequestMapping 单词修改之后 结果正常显示

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值