已编辑,仍然无法正常工作,但我需要在网站的每个页面上设置 page_type。该 page_type 需要由一些 java 检查并根据 page_type 执行代码。问题是,if else 语句没有正确完成。没有任何反应,因为似乎没有放置参数。正在设置 page_type 的主页:
<div id="DYK_area">
<jsp:include page="/imgs/random_dyk.jsp" flush="true">
<jsp:param name="Page_type" value="prenatalOverviewArea"></jsp:param>
</jsp:include>
</div>
检查代码的位置
<% String pageType = request.getParameter("page_type")==null?"": request.getParameter("page_type");
String image_name="";
if(pageType.equals("prenatalOverviewArea")){
int random = (int )(Math.random() * 10 + 1);
image_name= "/images/did_you_know/dyk_p_" + random + ".png";
}
else if(pageType.equals("prenatalNorm")){
int random = (int )(Math.random() * 25 + 1);
image_name= "/images/did_you_know/dyk_p_" + random + ".png";
}
else if(pageType.equals("overviewArea")){
int random = (int )(Math.random() * 20 + 1);
image_name= "/images/did_you_know/dyk_" + random + ".png";
}
else if(pageType.equals("overviewNorm")){
int random = (int )(Math.random() * 45 + 1);
image_name= "/images/did_you_know/dyk_" + random + ".png";
}
if(!image_name.equals("")){
%>
<img id="dyk_random" src="<%=image_name%>"/>
<%}%>