servlet url传递中文参数

表单:

<form name="UploadForm" action="<%=request.getContextPath()%>/servlet/uploadservlet" method="POST" style="margin: 0px" enctype="multipart/form-data">

 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类

你可能感兴趣的:(java,servlet)