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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

人生莫如饥荒

如果对您有帮助,也可以给点赏钱

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值