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

  • 相关阅读:
    关于工作
    5种风格的 jQuery 分页效果【附代码】
    轮播图jquery
    Microsoft.AspNetCore.Localization 自定义多语言获取
    10-微信小程序 WXS
    9-微信小程序引用
    8-微信小程序 事件
    7-微信小程序 模板(template)
    6-微信小程序 条件渲染 wx:if
    5-微信小程序 列表渲染 wx:for
  • 原文地址:https://www.cnblogs.com/famine/p/10040098.html
Copyright © 2011-2022 走看看