SpringMVC----RESTFUL_CRUD_删除操作&处理静态资源

2021-05-20 03:27

阅读:605

YPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

标签:springmvc   get请求   and   cli   服务器   图解   ota   通过   action   

1.

list.jsp


    pageEncoding="UTF-8"%>Insert title here




    
if test="${empty requestScope.employees }"> 没有任何员工信息. if> if test="${!empty requestScope.employees }">
ID LastName Email Gender Department Edit Delete
${emp.id } ${emp.lastName } ${emp.email } ${emp.gender == 0 ? ‘Female‘ : ‘Male‘ } ${emp.department.departmentName } Edit Delete
if>

Add New Employee springmvc.xml xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" xmlns:dubbo="http://code.alibabatech.com/schema/dubbo" xmlns:mvc="http://www.springframework.org/schema/mvc" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd"> package="com.yikuan.springmvc">bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> java代码 package com.yikuan.springmvc.crud.handlers; import java.util.Map; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import com.yikuan.springmvc.crud.dao.DepartmentDao; import com.yikuan.springmvc.crud.dao.EmployeeDao; import com.yikuan.springmvc.crud.entities.Employee; @Controller public class EmployeeHandler { @Autowired private EmployeeDao employeeDao; @Autowired private DepartmentDao departmentDao; @RequestMapping(value="/emp/{id}",method=RequestMethod.DELETE) public String delete(@PathVariable("id") Integer id){ employeeDao.delete(id); return "redirect:/emps"; } @RequestMapping(value="/emp",method=RequestMethod.POST) public String save(Employee employee){ employeeDao.save(employee); return "redirect:/emps"; } @RequestMapping(value="emp",method=RequestMethod.GET) public String input(Map map){ map.put("departments", departmentDao.getDepartments()); map.put("employee", new Employee()); return "input"; } @RequestMapping("/emps") public String list(Map map){ map.put("employees", employeeDao.getAll()); return "list"; } }

 

SpringMVC----RESTFUL_CRUD_删除操作&处理静态资源

标签:springmvc   get请求   and   cli   服务器   图解   ota   通过   action   

原文地址:https://www.cnblogs.com/yikuan-919/p/9741004.html


评论


亲,登录后才可以留言!