学习笔记总结2(阁瑞钛伦特软件-九耶实训)

6.
截取字符串函数,对网页中显示超长文字截短时使用:
**
   * 将字符串截短,取前n个字符,英文算半个字符。
   * @param orignalString 原字符串
   * @param length 长度
   * @param chopedString 超过部分的表示字符串
   * @return 截取的字符串
   */
  public static String chop(String orignalString,int length,String chopedString) {
    if (orignalString==null||orignalString.length()==0) {
      return orignalString;
    }
    orignalString=orignalString.replaceAll(" "," ");
    if (orignalString.length()<length) {
      return orignalString;
    }
    StringBuffer buffer=new StringBuffer(length);
    length=length*2;
    int count=0;
    int stringLength=orignalString.length();
    int i=0;
    for (;count<length&&i<stringLength;i++) {
      char c=orignalString.charAt(i);
      if (c<'\u00ff') {
        count++;
      } else {
        count+=2;
      }
      buffer.append(c);
    }
    if (i<stringLength) {
      buffer.append(chopedString);
    }
    return buffer.toString();
  }

7.
产生不大于X的数并且这个数大于Y
X-(X-Y)*Math.random()

8.
一个初始化的基本概念:
class Test{
   int i ; //class 的成员
   public void test() {
       System.out.println(i);//编译通过
       int j ;               //不是class的成员,必须手动初始化
       System.out.println(j); //失败 
   }
}

9.
页面上有一锚点,点击按钮去定位到锚点
 <input  type=button  οnclick=  "window.location.href  =  '#anchorName'  "  >

10.
在JSP文件中的<%%>中怎么“大语句段”注释?
<%--  
--%  >1.
......代码段......
<script language="javascript">
alert("数据插入成功");
</script>
<%response.sendRedirect("adddoc.jsp");%>
</body>  
</html>

以前我的意途是弹出一个对话框后再sendRedirect,因为JSP是在服务器端执行,所以必须这样:
<script language=javascript>
alert("数据插入成功");
location.href="adddoc.jsp";
</script>

2.
select * from table1 where ghy1 like '[a-z]'

这个语句查询A-Z的单个字母

如果一个人的名字是AA,,ZZ就查询不出来,何解:
select * from table1 where left(ghy1,1) between 'a' and 'z'
select * from table1 where ghy1 like '[a-z]%'

3.
随机抽取记录:
select top n * from tablename order by newid()

4.
使文本框和密码框高度一致:
<input type="text" style="height=20.0pt"><input type="password" style="height=20.0pt">

5.
文本域插入数据库时有特殊符号可以这样:
prep = conn.prepareStatement("insert into table values(?)");
prep.setString(1, request.getParameter("text"));
//这样无论有什么特殊字符都自动搞掂,无需转换

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值