js 下怎么找到当前项目名称
<%=getServletContext().getRealPath("/web/")%>
<%=request.getRequestURI()%><br>
<%=request.getContextPath()%><br>
<%=request.getRealPath("/")%><br>
<%=application.getRealPath("/")%><br>
<%=application.getRealPath(request.getRequestURI())%><br>
<%=new java.io.File(application.getRealPath(request.getRequestURI())).getParent()%>
除了第一,第二条(第二条跟第三条差别是一条/)以外,其他得出的结果是一样的,各位可以试下效果
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
document.forms[0].action="<c:out value='${pageContext.request.contextPath}' />/LoginAction.do?tag=loginOut";
document.forms[0].submit();
<link href="<html:rewrite page="/css/${systemStyle}/main.css" />" rel="stylesheet" type="text/css">
<script language="javascript" src="<html:rewrite page="/js/checkinput.js"/>"></SCRIPT>
<td width="100%" height="21" border="0" class="td_top" background="${pageContext.request.contextPath}/images/${systemStyle}/titleButton.gif" >
<frame noresize="noresize" name="top" scrolling="no" style="border-bottom:1px solid black;" frameborder=0 src="<%=request.getContextPath()%>/jsp/top.jsp">
这里要注意的是如果用了上面的 ${pageContext.request.contextPath} 表达式的の时候那么你的web.xml要保证头是这样的
<?xml version="1.0" encoding="gbk"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
确保是2.4的schema
function init()
{
var sort="<%=request.getParameter("sort")%>";
if(sort=="null"||""==sort)
{
sort="<%=Constant.FLOW_MAPS%>";
}
document.getElementById("sort").value=sort;
}
标签访问变量方法,还可以直接用el表达式语言。
<html:hidden write="true" property="theAccount.login_email" />
<bean:write name="AuditRecordForm" property="qinAuditFormEntity.audit_record_no"></bean:write>
<c:out value="${User_login_InSession.portal_id}" />