今天就是觉得老看别人代码,也看不懂,也改不会,还不如自己模仿着写个新的,希望能有所收获
jsp自动生成就会有
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
request.getScheme() 返回当前链接使用的协议;一般应用返回http;SSL返回https;
equest.getServerName()可以返回当前页面所在的服务器的名字;
request.getServerPort()可以返回当前页面所在的服务器使用的端口,就是80;
request.getContextPath()可以返回当前页面所在的应用的名字;
接着便是判断session了,
IUser user=(IUser)session.getAttribute("user")
if(user==null || user.getsession==null || user.getUserId.length()==0){
%>
<script language="JavaScript" type="text/javascript">
window.location="<%=basePath%>/login.jsp";
</script>
<%
return;
}
这段我也不懂,只能慢慢了解了
BaseForm baseForm = (BaseForm)request.getAttribute("itfForm");
String currAction="";
if(baseForm != null)
{
currAction=baseForm.getProgURI();
getProgURI()方法是获取原始的URI,讲道理我真的不知道啥叫原始URI!
if(currAction != null && currAction.length()>0)
{
int f=currAction.indexOf(request.getContextPath());
currAction=currAction.substring(f+request.getContextPath().length(),currAction.length());
}
}
浙公网安备 33010602011771号