⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 message_search.jsp

📁 实现复杂的分页查询
💻 JSP
字号:
<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%> 
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%><head>
<title>JSP for MessageSearchForm form</title>
</head>
<script language = "javascript">
function load()
{
document.forms[0].message_sts[1].checked = true;
document.forms[0].message_admin_sts[0].checked = true;
}
</script>
<script language = "javascript">
function checkChange()
{
   var oTRs = document.getElementsByName("checkbox");
   document.forms[0].button_Delete.disabled = true;
    if(oTRs.length == 1){
     if (document.forms[0].checkbox.checked)
     {
     document.forms[0].button_Delete.disabled = false;
     }
    }
 
   for(var i=0;i<oTRs.length;i++ )
   if( document.forms[0].checkbox[i].checked)
   {  
       document.forms[0].button_Delete.disabled = false;
   }
}
function checkAll()
{
 var oTRs = document.getElementsByName("checkbox");
 if(oTRs.length == 1){
 document.forms[0].checkbox.checked = true;
 document.forms[0].button_Delete.disabled = false;
 }
 for(var i=0;i<oTRs.length;i++ )
 {
  document.forms[0].checkbox[i].checked = true;
 }  
 document.forms[0].button_Delete.disabled = false; 
}
function checkdate(datetime)
  {
    checkdate = false;
    var date=datetime.substring(0,8);
    var year=parseInt(datetime.substring(0,4));
    var month=(datetime.substring(4,6));
    var day=(datetime.substring(6,8));
    if(datetime.length==8)//表示输入的日期长度要为8
    {
       if(month<13)
       {            
            if(month==01||month==03||month==05||month==07||month==08||month==10||month==12)
            {if(day<32){checkdate=true;}}    
            if(month==02&&(day<30&&year%4==0)||(day<29&&year%4!=0))                 
            {checkdate=true;}                
            if(month==04||month==06||month==09||month==11)     
            {checkdate=true;} 
         }                  
     }   
     return checkdate;            
  }                            
function checkDate(inputDate) 
{ 
if(inputDate!="") 
{ 
 var reg = /^(\d{4})(\d{2})(\d{2})$/; 
 if(reg.exec(inputDate)==null) 
 {return false;} 
 var year = RegExp.$1; 
 var month = RegExp.$2; 
 var day = RegExp.$3; 
 var d = new Date(month+"/"+day+"/"+year); 
 var dateStr = d.toLocaleString(); 
 newMonth = dateStr.substring(dateStr.indexOf("年")+1,dateStr.indexOf("月")); 
 if(newMonth!= parseInt(month,10).toString()) 
 { alert("Wrong Date"); return false;  }
 else 
 {return true; } 
 } 
} 
function checkLength(variant,len)
{
 if (variant.length > len)
 {return false;}
 else
 {return true;}
}   
function Check()
{
 Check = true;
 if(document.forms[0].date_from.value!= null && document.forms[0].date_from.value!= "" )
 { 
   if(checkDate(document.forms[0].date_from.value) == false)
   {alert("DateFrom Is Not A Date");document.forms[0].date_from.focus(); Check=false;}
 }
 if(document.forms[0].date_to.value!=null && document.forms[0].date_to.value!= "" )
 {
   if(checkDate(document.forms[0].date_to.value) == false)
   {alert("DateTo Is Not A Date");document.forms[0].date_to.focus();Check=false;}
 }
 if((document.forms[0].date_from.value != null && document.forms[0].date_from.value != "" )
    && (document.forms[0].date_to.value != null && document.forms[0].date_to.value != "" ))
 {
    if(document.forms[0].date_from.value > document.forms[0].date_to.value)
    {alert("DateTo Is Smaller Than DateFrom");Check=false;}
 }
 if (checkLength(document.forms[0].keyword.value,200) == false)
 { alert("keyword's Is Larger Than MaxLength(200)");document.forms[0].keyword.focus();Check=false;}
 return Check;
}                                        
function onSubmit()
{ 
 if(Check())
 {
  document.forms[0].action='messageSearch.do';
  document.forms[0].submit();
 }
 else
  document.forms[0].reset();
}
</script>

<html:html>
<style>   
.db { border-collapse:collapse;}
.db { border:1px;}     
.db tr{ background-color:expression('#AFAFAF,#F8F8F8'.split(',')[rowIndex>0&&rowIndex%2]); }
.dbt { border-collapse:collapse;}   
.dbt { border:1px;}
.dbt { border-color:#aaaaaa;}  
</style>
<style type="text/css">
<!--
P { font-size: 12pt; }
TH,TD { font-size: 10pt; }
-->
</style>
<body  onLoad="load()" background="C:\Documents and Settings\sei\workspace\TTC\WebRoot\image/bg.gif">
<html:form action="/messageSearch" >
<table border=1px align="center" cellspacing=0 cellpadding=0 class="dbt" bgcolor="#ffffff" >
<tr>
<td>
  <table width="850" border="0" align="center" bgcolor="#0099FF">
    <tr>
      <td width="600"rowspan=6> <html:img page="/image/kosha_head.gif" /></td>
      <td width="250"> 日本語/English</td>
    </tr>
    <tr>
      <td>Tokyo Trade Center</td>
    </tr>
    <tr>
      <td>提供:東京都</td>
    </tr>
    <tr>
      <td>所管:産業労働局</td>
    </tr>
    <tr>
      <td>運営:(財)東京都中小企業振興公社</td>
    </tr>
    <tr>
      <td>(一部は当公社が直接提供します)</td>
    </tr>
  </table>
  <p align="center">会員登録申請一覧
 <table border=1 align="center" cellspacing=0 cellpadding=0 class="dbt">
	<tr>
	<td>
  <table width="500" border="0" align="center" bgcolor="#6FC6FF">
    <tr>
      <td width="80"><bean:message key = "label.message_sts"/></td>
      <td width="100"><html:radio property="message_sts" value="既読"  />既読</td>
      <td width="100"><html:radio property="message_sts" value="未読"  />未読</td>
      <td width="100"><html:radio property="message_sts" value="全て"  />全て</td>
      <td width="100">&nbsp;</td>
    </tr>
    <tr>
      <td width="80" height="25"><bean:message key = "label.message_admin_sts"/></td>
      <td width="100"><html:radio property="message_admin_sts" value="未対応"  />未対応</td>
      <td width="100"><html:radio property="message_admin_sts" value="対応中"  />対応中</td>
      <td width="100"><html:radio property="message_admin_sts" value="対応済"  />対応済</td>
      <td width="100"><html:radio property="message_admin_sts" value="全て"  />全て</td>
    </tr>
    <tr>
      <td width="80" height="25"><bean:message key = "label.date_from"/></td>
      <td width="100"><html:text property="date_from" size="10" maxlength="8" value="${messageSearchForm.date_from}" /></td>
      <td width="100"><label>~</label><bean:message key = "label.date_to"/></td>
      <td width="100"><html:text property="date_to" size="10" maxlength="8" value="${messageSearchForm.date_to}" /></td>
       <td>&nbsp;</td>
    </tr>
    <tr>
      <td width="80" height="25"><bean:message key = "label.keyword"/></td>
      <td width="100"><html:text property="keyword" size="10" value="${messageSearchForm.keyword}" /></td>
      <td width="100"><html:submit property="button_Search" value="検索" onclick="javascript:onSubmit()"/></td>
      <td width="100"><label></label></td>
      <td width="100">&nbsp;</td>
    </tr>
  </table>
  	</td>
	</tr>
</table>

<logic:present name="result">
<bean:size id = "size" name = "result"/>
<logic:greaterThan name = "size" value = "0">
</logic:greaterThan>
<br><br>

<table border="0" width ="800" align="center">
<tr>
<td align="left">
<input type="button" name="check_all" value="すべてをチェック" onClick="javascript:checkAll()">
</td>
</tr>
</table>

<table border="1" width ="800" align="center" class="db">
<tr bgcolor="#9999FF">
<td align="center" width ="50">削除</td>
<td align="center" width ="120">メッセージ番号</td>
<td align="center" width ="80">状態</td>
<td align="center" width ="300">会社名</td>
<td align="center" width ="200">日付</td>
<td align="center" width ="100">対応</td>
</tr>
<logic:iterate id="message" name="result"  type="jp.co.ttc.sample.bean.Message" >
<logic:present name="message">
<tr>
      <td align="center"><html:checkbox name = "message" property="checkbox" value="${message.message_no}" onclick="javascript:checkChange()"/></td>
      <td><bean:write name = "message" property = "message_no" /></td>
      <td align="center">
      <logic:equal name = "message" property = "message_sts"  value = "0">
      <html:img page="/image/unread.JPG" />
      </logic:equal>
      <logic:equal name = "message" property = "message_sts"  value = "1">
      <html:img page="/image/read.JPG" />
      </logic:equal>
      </td>
      <td><bean:write name = "message" property = "company_name" /></td>
      <td><bean:write name = "message" property = "create_date" /></td>
      <td>
      <logic:equal name = "message" property = "admin_sts"  value = "0">
      <label>未対応</label>
      </logic:equal>
      <logic:equal name = "message" property = "admin_sts"  value = "1">
      <label>対応中</label>
      </logic:equal>
      <logic:equal name = "message" property = "admin_sts"  value = "2">
      <label>対応済</label>
      </logic:equal>
      </td>
</tr>
</logic:present>
</logic:iterate>
</table>
</logic:present>

  <table width ="800" align="center">
    <tr>
      <td align="left"><label>
        <html:submit  property="button_Delete"  value="削除" disabled = "true"/>
      </label></td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td align="right"><label>
        <html:submit property="button_Return"  value="戻る" onclick="javascript:window.open('form/denglu.jsp','newwindow','height=1000,width=1400,top=0,left=0,toolbar=no,menubar=no,scrollbars=no, resizable=no,location=no, status=no');"/> 
      </label></td>
    </tr>
  </table>
<logic:present name="result">
<table width ="400" align="center">
<tr>
<logic:equal name="page" property="hasPreviousPage" value="true">
<td align="right"><html:link page="/messageSearch.do?action=previousPage">≪前</html:link></td>
</logic:equal>
<logic:equal name="page" property="hasPreviousPage" value="false">
<td align="right"><label>≪前</label></td> 
</logic:equal>
<td align="center"><bean:write name="page" property="totalRows"/>件中の<bean:write name="page" property="pageStartRow"/>~<bean:write name="page" property="pageEndRow"/></td>
<logic:equal name="page" property="hasNextPage" value="true">
<td align="left"><html:link page="/messageSearch.do?action=nextPage">次≫</html:link></td> 
</logic:equal>
<logic:equal name="page" property="hasNextPage" value="false">
<td align="left"><label>次≫</label></td>
</logic:equal>
</tr>
</table>
</logic:present>
<br>
</td>
</tr>
</table>
</html:form>
</body>
</html:html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -