打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
应用程序路径 URL编码、解码
<%--
    Document   : test2
    Created on : 2010-3-25, 8:17:15
    Author     : Administrator
--%>
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.io.*" errorPage="" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>Untitled Document</title>
</head>
<body>
当前WEB应用的物理路径:<%=application.getRealPath("/")%><BR>
当前你求请的JSP文件的物理路径:<%=application.getRealPath(request.getRequestURI())%><BR>
<%
String path=application.getRealPath(request.getRequestURI());
String dir=new File(path).getParent();
out.println("当前JSP文件所在目录的物理路径"+dir+"</br>");
String realPath1 = "http://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath()+request.getServletPath().substring(0,request.getServletPath().lastIndexOf("/")+1);
out.println("web URL 路径:"+realPath1);
%>
<br>
<br>
<%
String path0 = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path0;
String uri = request.getRequestURI();
String q = request.getQueryString();
String url =basePath+uri+"?"+q ;
%>
<%=url %><br>
<%=basePath %><br>
<%
//String u = java.net.URLEncoder.encode("http://192.168.0.181:81/edit.jsp?pagenum=5&sub=中文");
String u = java.net.URLEncoder.encode("http://192.168.0.181:81/edit.jsp?pagenum=5&sub=中文","utf-8");
out.print(u);
//u=java.net.URLDecoder.decode(u);
u=java.net.URLDecoder.decode(u,"utf-8");
%>
<br>
<%=u%>
</body>
</html>
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
getRequestURI,getRequestURL的区别
YII路径总结
Struts2学习笔记----Path路径问题
jsp文件开头path, basePath作用
jsp获得当前路径的方法
jsp 和 Servlet中获取路径的各种方法总结
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服