您的位置:首页 > 其它

简单CMS项目笔记之二:前台页面处理流程

2012-12-05 23:27 411 查看
一:根目录的index.jsp

用户登录到index.jsp

<%@ page contentType="text/html; charset=gb2312"%>
<% response.sendRedirect("goindex.action"); %>
然后直接交给负责访问的action处理

二:IndexAction

通过struts的配置,跳转到此action

这个action中先用static静态块儿做了一些列初始化工作,比如通过Dao构建一个TreeMap保存所有信息的门类等

然后写到request和session中

request.setAttribute("allsublist",allsublist);
session.put("typeMap",typeMap);
session.put("searchMap",searchMap);


三:indexTemp.jsp

通过action返回SUCCESS,跳转到了真正显示信息的首页.

其中此页把网页分成了三行,最下边的页尾不用动态include

<%@ page language="java" contentType="text/html; charset=GBK"%>
<%@ taglib uri="/struts-tags" prefix="s2"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

String mainPage=(String)request.getAttribute("mainPage");
if(mainPage==null||mainPage.equals(""))
mainPage="default.jsp";
%>

<html>
<head>
<title>XXX_CMS信息网</title>
<base href="<%=basePath%>">
<link type="text/css" rel="stylesheet" href="css/style.css">
</head>
<body background="images/back.gif">
<center>
<table border="0" width="920" cellspacing="0" cellpadding="0" bgcolor="white">
<tr><td colspan="2"><jsp:include page="top.jsp"/></td></tr>
<tr>
<td width="230" valign="top" align="center"><jsp:include page="left.jsp"/></td>
<td width="690" height="400" align="center" valign="top" bgcolor="#FFFFFF"><jsp:include page="<%=mainPage%>"/></td>
</tr>
<tr><td colspan="2"><%@ include file="end.jsp" %></td></tr>
</table>
</center>
</body>
</html>


mainPage参数会去request里找(String)request.getAttribute("mainPage"),找不到的话显示“default.jsp”就行了

找到的话,信息是另一个action也是另一个模块填写进来的,后边再说具体写进来的是什么
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: