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 单词修改之后 结果正常显示