基于MVC的简易留言板




部分代码

index.jsp

<%@ page language="java" import="java.util.*,com.gc.model.SaveData" pageEncoding="utf-8"%>
    <%
    
    String path = request.getContextPath();
    String username=(String) request.getSession().getAttribute("username");

    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

    %>
    
    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en" class="no-js">
<head>
<link rel="shortcut icon" href="./messageBox_files/bitbug_favicon.ico" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
        <title>一个神奇的网站</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta name="description" content="">
        <meta name="author" content="">

        <!-- CSS -->
        <link rel='stylesheet' href='http://fonts.googleapis.com/css?family=PT+Sans:400,700'>
        <link rel="stylesheet" href="assets/css/reset.css">
        <link rel="stylesheet" href="assets/css/supersized.css">
        <link rel="stylesheet" href="assets/css/style.css">

	<style type="text/css" title="sidebar" id="sidebar">
	a:link {
    color:#FF0000;
    text-decoration:none;
    }
    </style>
        <!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
        <!--[if lt IE 9]>
            <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
        <![endif]-->
</head>
<body>

        <div class="page-container">
            <h1>Message Board</h1>
            <form action="/MessageBoard/LoginServlet" method="post">
                <input type="text" name="username" class="username" placeholder="Username">
                <input type="password" name="password" class="password" placeholder="Password">
                <button type="submit">登录</button>
                <div><h2>${errorinfo}</h2></div>
            </form>
            <br/>
        </div>
        <div align="center">
        <div id="sidebar">
        	<a  href="/MessageBoard/Register.jsp" title="Le Petit Prince">点击注册</a> 
        	  or  
        	<a  href="/MessageBoard/Logout?fk=fk" title="Le Petit Prince">访客模式</a>
        	</div>
        </div>


        <!-- Javascript -->
        <script src="assets/js/jquery-1.8.2.min.js"></script>
        <script src="assets/js/supersized.3.2.7.min.js"></script>
        <script src="assets/js/supersized-init.js"></script>
        <script src="assets/js/scripts.js"></script>

</body>
</html>
MessageBox。jsp
<%@ page language="java" import="java.util.*,com.gc.model.SaveData" pageEncoding="UTF-8"%>
<%
/* String path = request.getContextPath();
String username=(String) request.getSession().getAttribute("username");
if (username==null){
username="访客";
}
 */
String path = request.getContextPath();
String username ="";


if(request.getSession().getAttribute("username")==null){
request.getSession().setAttribute("username","访客");
username="访客";
request.getRequestDispatcher("/PageServlet").forward(request, response);
}else if(request.getAttribute("al")!=null){
	username = (String)request.getSession().getAttribute("username");
	}else{
	request.getRequestDispatcher("/PageServlet").forward(request, response);
	}
/*String username=(String) request.getAttribute("username");*/
ArrayList<SaveData> al = (ArrayList<SaveData>) request.getAttribute("al");
String pank = "";


String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>


<html >
<head>
<link rel="shortcut icon" href="./messageBox_files/bitbug
  • 2
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值