| 
         
     
     | 
     | 
    
  
    | 
    2月2日总结验证码,中文问题,jar命令,web组件的三种关联关系 | 
   
  
     | 
   
  
     | 
   
  
    | 
     作者:未知  来源:月光软件站  加入时间:2005-5-13 月光软件站  | 
   
  
    ===========网页产生四位的验证码:=========================
整数:
     <%
        	r=new Random();
		num=Math.abs(r.nextInt()%10000);
		String verifyNum=new Integer(num).toString();
     %>
double型
     	<%
		r=new Random();
		num=r.nextDouble()*10000;
		String verifyNum=new Double(num).toString(); 
	%>
==========jsp中文问题:============================================
where:页面显示|数据库读写|从上个页面的form中得到的中文参数|包含文件中的中文问题
解决方法:
    1、在jsp页面的顶部加上<%@ page contentType="text/html;charset=GB2312"%>
    2、strTemp=new String(strTemp.getBytes("ISO-8859-1"),"GB2312");
或strTemp=new String(strTemp.getBytes("UTF-8"),"GB2312");
    <%@ include file="../inc/security.jsp" encoding="GB2312"%>
当向数据库中插入时,先将Unicode->native code
当jdbc driver从数据库中查询时,将native code->Unicode
========jar的使用================================================
jar cvf test.jar test.class test.gif
==========建档应用程序javadoc的使用================================
例子
 第一步:(testHello.java保存在H:\java学习\2.2.javadoc)
/**这是一个用说明的java应用程序*/
pulic class testHello{
/**主函数,输出一句话
*/
	public static void main(String args[]){
		System.out.println("hello,恭喜你了!");
	}//main()
}/**testHello*/
第二步:cmd->H:\java学习\2.2.javadoc->javadoc testHello.java-> 回车.
此时,在H:\java学习\2.2.javadoc下面有10个.html文件,一个文件夹resources,一个stylesheet.css
========web组件的三种关联关系==================================
1请求转发,共享request范围中的数据
	servlet类使用javax.servlet.RequestDispatcher.forword()方法
		RequestDispatcher rd=request.getRequestDispatcher("hello.jsp");
		rd.forword(request,response);
	jsp中用
		
2重定向,不共享request范围中的数据
        response.sendRedirect("http://");
3包含
		RequestDispatcher rd=request.getRequestDispatcher("hello.jsp");
		rd.include(request,response);
	jsp中使用
		<%@include file="heder.jsp"%>	 
 
  | 
   
  
     | 
   
  
     相关文章:相关软件:  | 
   
   
      |