java后台代码:
package testLogMain;
import java.io.IOException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class logMain extends HttpServlet {
/**
* Constructor of the object.
*/
public logMain() {
super();
}
/**
* Destruction of the servlet. <br>
*/
public void destroy() {
super.destroy(); // Just puts "destroy" string in log
// Put your code here
}
/**
* The doGet method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to get.
*
* @param request
* the request send by the client to the server
* @param response
* the response send by the server to the client
* @throws ServletException
* if an error occurred
* @throws IOException
* if an error occurred
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doPost(request, response);
}
/**
* The doPost method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to
* post.
*
* @param request
* the request send by the client to the server
* @param response
* the response send by the server to the client
* @throws ServletException
* if an error occurred
* @throws IOException
* if an error occurred
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
// 设置编码方式
request.setCharacterEncoding("GBK");
// 转发请求
RequestDispatcher dispatcher = request
.getRequestDispatcher("logTable.jsp");
dispatcher.forward(request, response);
}
/**
* Initialization of the servlet. <br>
*
* @throws ServletException
* if an error occurs
*/
public void init() throws ServletException {
// Put your code here、
System.out.println("123");
}
}
web.xml配置信息:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>logQuery</servlet-name>
<servlet-class>testLogMain.logMain</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>logQuery</servlet-name>
<url-pattern>/logQuery</url-pattern>
</servlet-mapping>
</web-app>
JSP代码:页面排版可能有点乱,可以适当调整
top.jsp页面头部
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<script type="text/javascript" src="<%=basePath%>javascript/jquery-1.4.min.js"></script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>LOG</title>
</head>
<script type="text/javascript">
function currentDate(){
var nowdate = new Date();
$("#nowDate").empty();
$("#nowDate").text(new Date().toLocaleString());
setTimeout('currentDate()',1000);
}
window.setTimeout('currentDate()',1000);
</script>
<body>
<div>
<table align="center" border="0" cellpadding="0" cellspacing="0" width="99%">
<tr style="font-size:14px; color:#000000" bgcolor="#4169E1" height="30px">
<td align="left">
<font color="red">LOG信息</font>
</td>
<td>
<font id="nowDate"> </font>
</td>
</tr>
</table>
</div>
</body>
</html>
JSP页面查询logQuery.jsp利用iframe嵌套查询页面,include嵌套页面头部
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>日志查询</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<script type="text/javascript" src="<%=basePath%>javascript/jquery-1.4.min.js"></script>
<script type="text/javascript" src="<%=basePath %>javascript/selectdate.js"></script>
<script type="text/javascript" src="<%=basePath %>javascript/common.js"></script>
</head>
<script type="text/javascript">
//查询
function selectCaseRegister(){
queryForm.target = "frame1";
queryForm.submit();
}
</script>
<body bgcolor="#FFFFFF">
<form action="<%=basePath %>logQuery" name="queryForm" method="post">
<table width="98%">
<tr>
<td>
<jsp:include page="top.jsp" flush="true"/>
</td>
</tr>
</table>
<table align="center" width="98%" border="0" id="yxsqkTable" style="display:block;">
<tr>
<td>
<table align="center" width="98%" border="0" cellspacing="0" cellpadding="0" >
<tr bgcolor="#f5f5f5">
<td>
<legend >
查询条件
</legend>
<table width="98%" border="0" cellspacing="0" cellpadding="1" id="target_1" style="display:block" >
<tr>
<td>姓名: </td>
<td>
<s:textfield name=""></s:textfield>
</td>
<td>电话号码:</td>
<td>
<s:textfield name=""></s:textfield>
</td>
<td>工作年限:</td>
<td>
<s:textfield name=""></s:textfield>
</td>
</tr>
<tr>
<td style="text-align:right">
<input type="submit" οnclick="selectCaseRegister()" class="mybutton" value="查询" />
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<fieldset>
<legend>查询结果</legend>
<div>
<iframe src="" name="frame1" id="frame1" height="308" width="100%" marginwidth="0" marginheight="0" scrolling="no" frameborder="0" border="0" framespacing="0" noresize="noresize" vspale="0"></iframe>
</div>
</fieldset>
</td>
</tr>
</table>
</td >
</tr >
</table>
<!-- 有线索的情况结束 -->
</form>
</body>
</html>
JSP查询结果
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<base href="<%=basePath%>">
<title>记录查询</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<script type="text/javascript" src="<%=basePath%>javascript/jquery-1.4.min.js"></script>
<script type="text/javascript" src="<%=basePath%>javascript/page.js"></script>
<link rel="stylesheet" href="<%=basePath%>css/main.css" />
<style type="text/css">
.textBg{
background-color:#e9e6e6 ;
}
.t1{
color:#0000FF ;
text-decoration:none ;
}
td{
text-align:center ;
}
.t2{
color:#000000 ;
text-decoration:none ;
}
.textonlyread{
background:#F0F0F0
}
fieldset legend {
color:#1E7ACE;
font-weight:bold;
}
.tr:hover {
border: #99BBE8 1px solid;
background: #99BBE8;
}
.STYLE1 {color: #FF0000}
</style>
</head>
<script type="text/javascript">
$(document).ready(function(){
loadtable();
})
function fillCurrentId(id,currentState){
window.parent.document.getElementById("registerId").value = id;
window.parent.document.getElementById("currentState").value = currentState;
}
</script>
<body bgcolor="#FFFFFF">
<s:form>
<s:hidden name="countPage" id="countPage" />
<s:hidden name="countRow" id="countRow" />
<s:hidden name="currPage" id="currPage" />
<table width="99%" align="center" border="1" cellspacing="0" cellpadding="3">
<tr style="background-image: url('<%=basePath %>image/one_result.jpg')">
<th scope="col">序号</th>
<th scope="col">选择</th>
<th scope="col">登记日期</th>
<th scope="col">姓名</th>
<th scope="col">工作年限</th>
<th scope="col">手机号码</th>
</tr>
<s:iterator value="vector" id="regInfo" status="st">
<tr class="tr" bgcolor="<s:if test='#st.odd==true'></s:if><s:else>#eceaeb</s:else>">
<td>
1
</td>
<td>
<input type="radio" name="radiobutton" value="<s:property value='id'/>" οnclick="fillCurrentId('${regInfo.id }','${regInfo.currentState }')"/>
</td>
<td>
1991-1-2
</td>
<td>
张三
</td>
<td>
3
</td>
<td>
1234567890
</td>
</s:iterator>
</table>
</s:form>
</body>
</html>