您的位置:首页 > 编程语言 > Java开发

2月2日总结验证码,中文问题,jar命令,web组件的三种关联关系

2005-03-09 10:31 381 查看
===========网页产生四位的验证码:=========================
整数:
<%
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"%>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息