posts - 110, comments - 101, trackbacks - 0, articles - 7
  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理

前提引入jquery.js

 1$(document).ready(function() {
 2            $('#searchform input').keyup(trimkeyup);
 3}
);
 4function trimkeyup(e) {
 5    lucene_objInput = $(this);
 6    if (e.keyCode != 38 && e.keyCode != 40 && e.keyCode != 13{
 7        var im = $.trim(lucene_objInput.val());
 8        lucene_objInput.val(im); 
 9    }

10}
        



 1        <form id="searchform" name="searchform" action="listPsInfo.action" method="post">
 2        <div id="sr" class="b1 mb10">
 3            <ul id="sr_bq">
 4                <li class="on">
 5                    <div>
 6                        查询员工信息
 7                    </div>
 8                </li>
 9            </ul>
10            <select class="sa_w_tx" style="width: 100px;" id="selectType" name="psInfoDO.name">
11                  <option value="1" <s:if test="optionValue==1">selected="selected"</s:if>>工号</option>
12                  <option value="2" <s:if test="optionValue==2">selected="selected"</s:if>>旺旺(花名)</option>
13                  <option value="3" <s:if test="optionValue==3">selected="selected"</s:if>>真实姓名</option>
14                  <option value="4" <s:if test="optionValue==4">selected="selected"</s:if>>邮箱</option>
15            </select> 
16            <input type="text" class="sa_w_tx" style="width: 180px;" id="textValue" name="psInfoDO.value" value="<s:property value="psInfoDO.value"/>" maxlength="100" title="请输入相应内容  不允许空值" />&nbsp;&nbsp;
17             <input type="button" value="查询" class="btn1" id="subform" onclick="dosearch();"/>&nbsp;&nbsp; <div id="errortip"></div>
18            </form>

页面中所有的input输入框都会自动过滤前后空格

posted @ 2011-03-02 17:24 云云 阅读(6930) | 评论 (5)编辑 收藏

在数据库中定义长度 那么在代码中我们做校验的时候也需要注意
在数据库中的长度 就是java类的length

如:VARCHAR2(50 CHAR)
psInfos.getTruename().length()>50
用50作边界

如:VARCHAR2(100)
 psInfos.getIm().length()>100 用100作边界

posted @ 2011-03-02 17:14 云云 阅读(778) | 评论 (0)编辑 收藏

如果equals的左边是空值 会出现空指针异常
public class Test {
    
public static void main(String[] args) {
           String string
=null;
           
if(!string.equals(""))
           
{
               System.out.println(
"---------");
           }

    }

    
}
Exception in thread "main" java.lang.NullPointerException
    at com.taobao.Test.main(Test.java:
6)

如果把可能为空的变量放在右边 不会有事
 1public class Test {
 2    public static void main(String[] args) {
 3           String string=null;
 4           if(!"ccc".equals(string))
 5           {
 6               System.out.println("---------");
 7           }

 8    }

 9}

10
运行结果 打印出虚线
---------

posted @ 2011-03-02 17:07 云云 阅读(15991) | 评论 (0)编辑 收藏

jsp页面查询数据  取出date类型字段

java 类
1     private Date createtime;
2     private Date updatetime;
 1     public Date getCreatetime()
 2     {
 3         return createtime;
 4     }
 5 
 6     public void setCreatetime(Date createtime)
 7     {
 8         this.createtime = createtime;
 9     }
10 
11     public Date getUpdatetime()
12     {
13         return updatetime;
14     }
15 
16     public void setUpdatetime(Date updatetime)
17     {
18         this.updatetime = updatetime;
19     }

jsp页面:
 1                     <s:if test="jobChangeList.size()>0">
 2                                         <s:iterator value="jobChangeList">
 3                                             <tr>
 4                                                 <td>
 5                                                     <s:date name="createtime" format="yyyy-MM-dd" nice="false" />
 6                                                 </td>
 7                                             </tr>
 8                                         </s:iterator>
 9                                     </s:if>
10                                     <s:else>没有相关记录</s:else>


如果要取到时分秒的话 更改一下格式即可:
<s:date name="networkUserDO.createtime" format="yyyy-MM-dd HH:mm:ss"/>
结果:2009-04-16 13:26:29

posted @ 2011-03-02 16:55 云云 阅读(5521) | 评论 (0)编辑 收藏

在jsp页面使用s:if来判断 和使用s:date来格式化时间显示方式



 1                                     <s:if test="jobChangeList.size()>0">
 2                                         <s:iterator value="jobChangeList">
 3                                             <tr>
 4                                                 <td>
 5                                                    <s:if test="employeetype==0">正式员工  </s:if>
 6                                                    <s:elseif test="employeetype==1">外包  </s:elseif>
 7                                                    <s:elseif test="employeetype==2">实习生</s:elseif>
 8                                                    <s:else></s:else>
 9                                                 </td>
10                                                 <td>   
11                                                    <s:if test="dimission==1">在职  </s:if>
12                                                      <s:elseif test="dimission==2">离职 </s:elseif>
13                                                   </td>
14                                             </tr>
15                                         </s:iterator>

字符
<s:iterator value="adboardDOList"> 页面直接遍历action提供的数据
 
<td class="align-center"> 
     
<s:if test='status == "P"'>
       
<span class="c-ok">审核通过</span>
     
</s:if>
                
<s:elseif test='status == "W" '>
                  待审核
                
</s:elseif>      
                
<s:elseif test='status=="R"'>
                  
<span class="c-warn">审核拒绝</span> <span class="icon icon-warning" title="<s:property value='comments'/>"></span>
                
</s:elseif>        
            
</td>
注意 这里如果status类型是字符串类型 在if中外层用的是单引号 里面用双引号 
串类型





 1 <s:set name="age" value="61"/> 页面通过set赋值 同时在页面上判断
 2  <s:if test="${age > 60}"> 
 3     老年人 
 4 </s:if>
 5 <s:elseif test="${age > 35}">
 6     中年人
 7 </s:elseif>
 8 <s:elseif test="${age > 15}" id="wawa">
 9     青年人
10 </s:elseif>
11 <s:else>
12     少年
13 </s:else>
14 2  从后台数据库中取出值通过对对象传到页面 
15 <s:if test="psInfoDO.employeetype==0">正式员工  </s:if>
16 <s:elseif test="psInfoDO.employeetype==1">外包  </s:elseif>
17 <s:elseif test="psInfoDO.employeetype==2">实习生</s:elseif>
18 3
19 <s:set name="name" value="<%="'"+ request.getParameter("name")+"'" %>"/>
20 <%
21   System.out.println(request.getParameter("name"));
22  %>
23 <s:if test="#name=='zhaosoft'">
24   zhaosoft here
25 </s:if>
26 <s:elseif test="#name=='zxl'">
27   zxl here
28 </s:elseif>
29 <s:else>
30   other is here 
31 </s:else>

字符串比较的时候 注意加引号 
 

posted @ 2011-03-02 16:46 云云 阅读(35891) | 评论 (4)编辑 收藏

项目中使用struts2 在页面中提交表单后将查询结果显示在本页面  但是要求保留输入框的查询内容  



jsp页面
1     function dosearch() {
2         if ($("#textValue").val() == "") {
3                 $("#errortip").html("<font color='#FF0000'>请输入查询内容</font>");
4             return false;
5         }
6         $('#searchform').submit();
7     }


 1         <form id="searchform" name="searchform" action="listPsInfo.action" method="post">
 2         <div id="sr" class="b1 mb10">
 3             <ul id="sr_bq">
 4                 <li class="on">
 5                     <div>
 6                         查询员工信息
 7                     </div>
 8                 </li>
 9             </ul>
10             <select class="sa_w_tx" style="width: 100px;" id="selectType" name="psInfoDO.name">
11                   <option value="1" <s:if test="optionValue==1">selected="selected"</s:if>>工号</option>
12                   <option value="2" <s:if test="optionValue==2">selected="selected"</s:if>>旺旺(花名)</option>
13                   <option value="3" <s:if test="optionValue==3">selected="selected"</s:if>>真实姓名</option>
14                   <option value="4" <s:if test="optionValue==4">selected="selected"</s:if>>邮箱</option>
15             </select> 
16             <input type="text" class="sa_w_tx" style="width: 180px;" id="textValue" name="psInfoDO.value" value="<s:property value="psInfoDO.value"/>" maxlength="100" title="请输入相应内容  不允许空值" />&nbsp;&nbsp;
17              <input type="button" value="查询" class="btn1" id="subform" onclick="dosearch();"/>&nbsp;&nbsp; <div id="errortip"></div>
18             </form>

为了保留下拉列表框中的值 处理办法是在提交表单到action中的时候将option中的值用一个变量optionValue来保存 这样在页面返回后将这个optionValue带回到
jsp使用struts2标签s:if 作判断就可以使用下拉框的值保留了 
1 <option value="1" <s:if test="optionValue==1">selected="selected"</s:if>>工号</option>


普通的input输入框可以使用action中的域模型就可以了

action:
1     private IPeoplesoftInfoBO peoplesoftInfoBO;
2     private PeoplesoftInfoDO psInfoDO;
3     private PeoplesoftInfoDO querypsInfo;
4     private String optionValue;


 1     public String listPsInfo() throws Exception {
 2         
 3         this.optionValue=psInfoDO.getName();
 4         this.querypsInfo=peoplesoftInfoBO.findPsInfoByConditions(psInfoDO);
 5     
 6         if(querypsInfo==null)
 7             {
 8                 addFieldError("userLogNameMessage","系统不存在该员工信息,请核对后手工设置该操作人员的基本信息");
 9             }
10         return SUCCESS;
11     }

posted @ 2011-03-02 14:53 云云 阅读(11022) | 评论 (6)编辑 收藏

仅列出标题
共12页: First 上一页 4 5 6 7 8 9 10 11 12