比如说"http://localhost:8084/LabSite/NewJplusServlet.jsp?mode=SHOWLIST&page=1
把它用URLEncoder.encode("http://localhost:8084/LabSite/NewJplusServlet.jsp?mode=SHOWLIST&page=1","UTF-8")变成乱码 然后放到浏览器地址栏中 然后再后台解码进行操作,怎么实现 求大神指导
把它用URLEncoder.encode("http://localhost:8084/LabSite/NewJplusServlet.jsp?mode=SHOWLIST&page=1","UTF-8")变成乱码 然后放到浏览器地址栏中 然后再后台解码进行操作,怎么实现 求大神指导
解决方案 »
- [求助]struts2整合spring,无法注入service
- 把一段文字写在本地硬盘,写成.txt的形式怎么了?类似于“另存为”那样的按纽
- 数据库连接错误The Network Adapter could not establish the connection
- 问个jsp读取文件的问题
- 绝对挑战:如何解决存储过程返回参数限制4K长度的问题?
- 如何让TOMCAT使用HTTP1.0,而不是HTTP1.1?
- 关于getParameterValues的一个非常奇怪的问题
- 求教一个配置的问题(在线等待)
- 斑主,怎么知道自己贴子是否已结贴?
- 这个3d电影选座怎么获取选择座位的值。求助求助!!!
- 投票网站如何限制刷票大军
- 如何用ajax,json实现发送xml到服务器端,再解析从服务器端返回的xml?
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();
}
}
}