老師為何JSP頁面的作者不顯示,還有開始留言那一欄也不顯示?
sevlert代碼
package servlet;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import domain.User;
import services.UserServices;
/**
* Servlet implementation class Login
*/
@WebServlet("/Login")
public class Login extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public Login() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
* response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
* response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String username = request.getParameter("username");
String password = request.getParameter("password");
String yzm = request.getParameter("code");
System.out.println(username + " " + password);
String kaptchaExpected = (String) request.getSession()
.getAttribute(com.google.code.kaptcha.Constants.KAPTCHA_SESSION_KEY);
User u = new User();
u.setName(username);
u.setpassword(password);
UserServices us = new UserServices();
User exitUser = us.login(u);
if (exitUser != null ) {
request.getSession().setAttribute("user", exitUser);
if(kaptchaExpected.equals(yzm)){
request.getRequestDispatcher("/message_list.jsp").forward(request, response);
}
else{
response.setContentType("text/html;charset=utf-8");
response.getWriter().print("验证码错误");
request.getRequestDispatcher("/login.jsp").forward(request, response);
}
}
}
}
jsp代碼
<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<html>
<head>
<meta charset="UTF-8">
<title>我的留言</title>
<link rel="stylesheet" href="css/index.css">
<link rel="stylesheet" href="css/bootstrap.min.css">
<script type="text/javascript">
</script>
</head>
<body>
<header>
<div class="container">
<%
if (null != request.getSession().getAttribute("user")) {
%>
<nav>
<a href="">我的留言</a>
</nav>
<nav>
<a href="">我的信息</a>
</nav>
<%
} else {
%>
<nav>
<a href="">登录</a> <a href="">注册</a>
</nav>
<%
}
%>
</div>
</header>
<section class="banner">
<div class="container">
<div>
<h1>慕课网留言板——我的留言</h1>
<p>慕课网是垂直的互联网IT技能免费学习网站。以独家视频教程、在线编程工具、学习计划、问答社区为核心特色。在这里,你可以找到最好的互联网技术牛人,也可以通过免费的在线公开视频课程学习国内领先的互联网IT技术。
</p>
</div>
</div>
</section>
<section class="main">
<div class="container">
<div class="alt-item">
<div class="alt-head">
<div class="alt-info">
<span>作者:${user.name}<a href=""></a></span> <span>时间:</span>
</div>
</div>
<div class="alt-content">
<h3>慕课网好</h3>
<p>慕课网好</p>
</div>
<div align="right">
<table>
<tr>
<td>
<button class="btn btn-primary" type="submit">
<a href="${pageContext.request.contextPath}/edit_message.jsp"><font
color="white">修改</font></a>
</button>
</td>
<td>
<button class="btn btn-primary" type="submit">删除</button>
</td>
</tr>
</table>
</div>
</div>
</div>
</section>
<section class="page">
<div class="container">
<!-- 分页内容参考视频中老师源码 -->
</div>
</section>
<div class="container">
<nav>
<a href="">开始留言</a>
</nav>
</div>
<footer> copy@慕课网 </footer>
</body>
</html>
正在回答 回答被采纳积分+1
- 参与学习 人
- 提交作业 357 份
- 解答问题 8016 个
本阶段将带你学习MySQL数据库,JDBC接口,MyBatis框架等,带你掌握的数据的存放和管理。
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星