ITeye博客

jsp开发中中文传值加密解密,解决乱码问题

CN.Silva... · 2008-05-06 14:44 · 程序 & 理念 · Java · .net · JSP · Markdown

一:

 页面使用js加密:            

     user = window.encodeURI(user);           

     user = window.encodeURI(user);           

     document.location.href = "/communion.do?action=updateSpace&id=" + id + "&user=" + user;    

其中user为中文,注意:一定要加密两次;

二:

 java代码解密:            

      String user = java.net.URLDecoder.decode(request.getParameter("user"),"UTF-8");   

  解密;

三:

   转码:           

         private String convert(String str) throws UnsupportedEncodingException {                   

                      return new String(str.getBytes(),"GBK");          

         }

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。