path = request.getcontextpath()有什么用
来源:百度知道 编辑:UC知道 时间:2024/06/19 06:49:14
有这样一段代码,是干什么用的???
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
希望高手帮帮忙~
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
希望高手帮帮忙~
这样的代码是在jsp里出现的吧,
那么他的含义就是为了得到一个路径,
做动态网站时,需要提交form表单
在表单的action里面就会这样来写
action="<%=path %>/add.do"
这样来提交到相应的servlet中去,这样可以避免路径的错误,而采用这样的相对路径会更好些
request.getContextPath()应该是得到项目的名字,如果项目为根目录,则得到一个"",即空的字条串,
如果项目为abc, <%=request.getContextPath()% >/ 将得到abc/,服务器端的路径则会自动加上
这样写的目的就是获得一个绝对路径,与action=" ";相对应。
获得的当前目录路径
在J2EE的API帮助里有
request.querystring("path")
echo "path = $PATH";
server.mappth(request.form("path"))这样写为什么不行呢?
不用request如何实现id=request(id)??
Win98系统盘跟目录下的AutoExec.bat文件里有SET PATH=%PATH%语句。
request.form.count=0是什么意思?
Fy_Url=Request.ServerVariables("QUERY_STRING")
<%=request("msg")%>
userip = nosql(Request.("HTTP_X_FORWARDED_FOR"))
ASP的ParaValue=Request(ParaName)是什么意思?