问题记录及解决

一、ajax中文参数传递时的乱码问题

前端JS代码:

typeselect=encodeURI(typeselect); 
form2.action="xxxx.do?typeselect="+typeselect; 
form2.submit(); 

后台JAVA代码:

import java.net.URLDecoder; 

if(request.getParameter("typeselect") != null) { 
    typeid = request.getParameter("typeselect"); 
    typeid =URLDecoder.decode(typeid, "utf-8"); 
} 

二、利用Struts1的DownloadAction实现邮件中附件下载弹窗功能

前端代码:

 <a href='documentdown.do?id=documentId'>文档标题</a>
Action配置:
 <action path="/documentdown" scope="request"
		type="com.longshine.cicada.wdgl.action.DocumentDownAction">  
 </action>
Java代码:
public class DocumentDownAction extends DownloadAction {


	@Override
	protected String getFilename(HttpServletRequest request,
			net.vicp.hbwf.web.struts.form.ActionForm form) throws Exception {
		String id= request.getParameter("id");
		String filename = WdglAPI.getFileName(request, id);
		return StringUtils.isNotBlank(filename) ? URLEncoder.encode(filename, "UTF-8") : GUID.newSimpleGUIDStr();
	}


	@Override
	protected InputStream getInputStream(HttpServletRequest request,
			net.vicp.hbwf.web.struts.form.ActionForm form) throws Exception {
		String id= request.getParameter("id");
		return WdglAPI.getFileContent(request, id);
	}		
}









你可能感兴趣的:(问题)