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



一:根目录的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也是另一个模块填写进来的,后边再说具体写进来的是什么





















  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值