比如说"http://localhost:8084/LabSite/NewJplusServlet.jsp?mode=SHOWLIST&page=1 
把它用URLEncoder.encode("http://localhost:8084/LabSite/NewJplusServlet.jsp?mode=SHOWLIST&page=1","UTF-8")变成乱码   然后放到浏览器地址栏中   然后再后台解码进行操作,怎么实现  求大神指导

解决方案 »

  1.   

    你想问的是什么解码吗?可以用URLDecoder.decode()方法
      

  2.   

    你在超链接里面的url加密,后台解密这个url请求就行了
      

  3.   

    你是想说以这样post的方式提交请求么?public static void main(String[] args) {
      URL url = null;
      HttpURLConnection httpurlconnection = null;
      try {
       url = new URL("http://www.ip138.com/ips.asp");
       httpurlconnection = (HttpURLConnection) url.openConnection();
       httpurlconnection.setDoInput(true);
       httpurlconnection.setDoOutput(true);   httpurlconnection.setRequestMethod("POST");
       httpurlconnection.setRequestProperty("Content-Type",
         "application/x-www-form-urlencoded");   String username = "ip=192.168.0.1";
       httpurlconnection.getOutputStream().write(username.getBytes());   httpurlconnection.getOutputStream().flush();
       httpurlconnection.getOutputStream().close();
       int code = httpurlconnection.getResponseCode();
       System.out.println("code    " + code);   if (code == 200) {    String cookie = httpurlconnection.getHeaderField("Set-Cookie ");
        System.out.println(cookie);
        // httpurlconnection.setRequestProperty( "Cookie", cookie);    DataInputStream in = new DataInputStream(httpurlconnection
          .getInputStream());
        int len = in.available();
        byte[] by = new byte[len];
        in.readFully(by);
        String rev = new String(by);
        System.out.println(rev);
        in.close();
       }
      } catch (Exception e) {
       e.printStackTrace();
      } finally {
       if (httpurlconnection != null) {
        httpurlconnection.disconnect();
       }
      }
     }
      

  4.   

    我是想把网址的跳转的正确路径给掩盖住   比如说要跳转到http://localhost:8084/LabSite/NewJplusServlet.jsp?mode=SHOWLIST&page=1  这个页面    然后我把他用URLEncoder.encode("http://localhost:8084/LabSite/NewJplusServlet.jsp?mode=SHOWLIST&page=1","UTF-8"); 这个乱码后    然后我浏览这个网页  浏览器网址只会显示http%3A%2F%2Flocalhost%3A8084%2FLabSite%2FNewJplusServlet.jsp%3Fmode%3DSHOWLIST%26page%3D1 这路径给你   怎么实现
      

  5.   

    我是想把网址的跳转的正确路径给掩盖住   比如说要跳转到http://localhost:8084/LabSite/NewJplusServlet.jsp?mode=SHOWLIST&page=1  这个页面    然后我把他用URLEncoder.encode("http://localhost:8084/LabSite/NewJplusServlet.jsp?mode=SHOWLIST&page=1","UTF-8"); 这个乱码后    然后我浏览这个网页  浏览器网址只会显示http%3A%2F%2Flocalhost%3A8084%2FLabSite%2FNewJplusServlet.jsp%3Fmode%3DSHOWLIST%26page%3D1 这路径给你   怎么实现