zoukankan      html  css  js  c++  java
  • ssm框架整合入门系列——修改-员工的修改

    ssm框架整合入门系列——修改-员工的修改

    修改操作的保存员工数据方法用了put提交方式,
    这有一个有意思的问题,由于tomcat reqeust.java自身的问题,导致 request.getParameter("empNmae") 拿不到put方式提交请求体的数据。
    解决办法,在web.xml中配置HttpPutFormContentFilter

      <!-- 解决更新员工 无法直接使用put提交方式-->
      <filter>
      	<filter-name>HttpPutFormContentFilter</filter-name>
      	<filter-class>org.springframework.web.filter.HttpPutFormContentFilter</filter-class>
      </filter>
      <filter-mapping>
      	<filter-name>HttpPutFormContentFilter</filter-name>
      	<url-pattern>/*</url-pattern>
      </filter-mapping>
    

    saveEmp()

    	@Autowired
    	EmployeeService employeeService;
    	
    	/**
    	 * 在web.xml中配置HttpPutFormContentFilter类
    	 * 以支持put提交方式
    	 * 
    	 * 员工更新
    	 * @param employee
    	 * @return
    	 */
    	@ResponseBody
    	@RequestMapping(value="/emp/{empId}",method=RequestMethod.PUT)
    	public Msg saveEmp(Employee employee){
    		
    		//System.out.println(employee);
    		employeeService.updateEmp(employee);
    		return Msg.success();
    	}
    

    ajax请求

    //2.发送ajax请求保存员工的更新
      			$.ajax({
      				url:"${path}/ssm-crud/emp/"+$(this).attr("edit-id"),
      				type:"PUT",
      				data:$("#empUpdateModal form").serialize(),
      				success:function(result){
      					//alert(result.msg);
      					//1.关闭模态框
      					$("#empUpdateModal").modal("hide");
      					//2.回到本页面
      					to_page(currentPage);
      				
      				}
      			})
    

    END

  • 相关阅读:
    实现一个圆形进度条
    给你的jQuery项目赋予Router技能吧
    matlab新手入门(四)(翻译)
    matlab新手入门(三)(翻译)
    matlab新手入门(二)(翻译)
    matlab新手入门(一)(翻译)
    安装Matlab出现Error 1935错误解决方法
    Linux Ubuntu下Jupyter Notebook的安装
    lung 分割论文
    链表的回文结构
  • 原文地址:https://www.cnblogs.com/famine/p/10040098.html
Copyright © 2011-2022 走看看