解决ext+struts传递中文参数的乱码的问题

1、前端

 var filePath="d:/三方协议模板.docx";
 var fileName="三方协议模板.docx"; 
 var url=base.host+'/ggfwFileInfoMng!threeProtocalDownLoad.do?timestamp='+new Date().getTime()+'&pojo.file_url='+encodeURI(encodeURI(filePath))+'&pojo.file_name='+encodeURI(encodeURI(fileName));
 // var url=base.host+'/ggfwFileInfoMng!threeProtocalDownLoad.do?timestamp='+new Date().getTime();
 location.href =url;

 

2、后台

GgfwFileInfo fileInfo=(GgfwFileInfo)this.pojo;

 String filePath = fileInfo.getFile_url();
   String fileName = fileInfo.getFile_name();
   filePath = URLDecoder.decode(filePath, "UTF-8");
   fileName = URLDecoder.decode(fileName, "UTF-8");

 

总结:(1)struts将request封装到内部,利用pojo.属性的名字,形式接收参数,前端两次encodeURI(),后台借助于URLDecoder.decode(fileName,"UTF-8")

你可能感兴趣的:(解决ext+struts传递中文参数的乱码的问题)