zoukankan      html  css  js  c++  java
  • 6月

    6-19 读取property的方法   http://blog.csdn.net/tornadowp/article/details/8049548

    6-20

    1、在<%@include file="" %>的文件中添加

    <%
        String contextPath = request.getContextPath();
        String basePath = request.getScheme() + "://" + request.getServerName() + ":"+request.getServerPort() + contextPath;
        pageContext.setAttribute("basePath", basePath);
    %>

    便可以在jsp中得到basePath的值

    6-22

    1、java随机数有两种方式:一种为Math.random生成0-1的随机数,另外一种是util的Random 利用nextInt(11)生成0-10的自然数,

      若要生成一个随机的字符串,可以将已知的字符生成一个数组,然后利用nextInt再去生成字,拼接起来便可,例如验证码便可以这样生成

    2、随机选取不重复的数字,

    3、字符串  "0123456789".toCharArray();便可以生成char类型的数组

      Integer.parseInt(Str),字符串转int  Integer.valueOf(Str).intValue()

     6-23

    1、servlet   response.getOutputStream().write() 可以输出byte【】类型的数据给页面 byte[] data="中国".getBytes("utf-8")

      而response.getWriter.write() 加的参数为char[] 数组 输出时需要提前设置setCharacterEncoding 必须在前面

      response.setHeader("content-type", "text/html;charset=UTF-8"); 用来控制浏览器返回解析时候用的编码格式
      等同于response.getWriter().write("<meta http-equiv='content-type' content='text/html;charset=UTF-8'/>"); 
    注意:输出的文本 必须转成字符串在 getBytes 才可以输出,例如数字 1 也必须转成 1+“”。getBytes(“utf-8”) 才可以输出到浏览器中
  • 相关阅读:
    JQ选择器
    设计模式
    招银网络面试
    斗鱼面经
    招银科技面经
    用户访问网站基本流程
    shell的条件判断
    crontab -e 和/etc/crontab的区别
    秘钥对登录配置
    CentOS6 x86_64最小化安装优化脚本
  • 原文地址:https://www.cnblogs.com/happy0120/p/7048342.html
Copyright © 2011-2022 走看看