servlet url传递中文参数

阅读更多

表单:

 js:

//测试传参数的方法
        var action = document.getElementById("UploadForm").action
        var test = escape(escape("中文"));
        document.getElementById("UploadForm").action = action + "?page=test&test=" + test;
        
        document.getElementById("UploadForm").submit();
        document.getElementById("UploadForm").reset();

 

java:doPost

/**
     * Handles POST requests   处理上传请求
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    	 String page = request.getParameter("page");
         String test = Escape.unescape(request.getParameter("test"));

 可取得page值为test,test值为"中文"。

 

附件为Escape.java类

  • Escape.rar (1.2 KB)
  • 下载次数: 148

你可能感兴趣的:(Servlet,Java)