java¾²Ì¬ÍøÒ³¼¼Êõ
±¾ÎļÙÉèÄãÊÇÓÃjava¿ª·¢µÄweb¶¯Ì¬Ò³Ãæ¡£
µÚÒ»²½£¬¼ÓÈëservlet.´úÂëÈçÏ¡£
public class ToHtml extends HttpServlet {
public void service(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String url = "";
String name = "";
ServletContext sc = getServletContext();
String file_name = request.getParameter("file_name");// ÄãÒª·ÃÎʵÄjsp ÎļþÃû,Èçindex£¬²»°üÀ¨À©Õ¹Ãû
// ÔòÄã·ÃÎÊÕâ¸öservletʱ¼Ó²ÎÊý.Èçhttp://localhost/test/toHtml?file_name=index
url = "/" + file_name + ".jsf";// ÄãÒªÉú³ÉµÄÒ³ÃæµÄÎļþÃû¡£ÎÒµÄÀ©Õ¹ÃûΪjsf .
name = ConfConstants.CONTEXT_PATH+"\\"+ file_name + ".htm";// ÕâÊÇÉú³ÉµÄhtmlÎļþÃû,Èçindex.htm.ÎļþÃû×ÖÓëÔ´ÎļþÃûÏàͬ¡£À©Õ¹ÃûΪhtm
//ConfConstants.CONTEXT_PATHΪÄãµÄÓ¦ÓõÄÉÏÏÂÎÄ·¾¶¡£
RequestDispatcher rd = sc.getRequestDispatcher(url);
final ByteArrayOutputStream ōs = new ByteArrayOutputStream();
final ServletOutputStream stream = new ServletOutputStream() {
public void write(byte[] data, int offset, int length) {
os.write(data, offset, length);
}
public void write(int b) throws IOException {
os.
Ïà¹ØÎĵµ£º
import
java.util.Random;
/**
*
ÅÅÐò²âÊÔÀà
*
*
ÅÅÐòËã·¨µÄ·ÖÀàÈçÏ£º
*
1.
²åÈëÅÅÐò£¨Ö±½Ó²åÈëÅÅÐò¡¢ÕÛ°ë²åÈëÅÅÐò¡¢Ï£¶ûÅÅÐò£©£»
*
2.
½»»»ÅÅÐò£¨Ã°ÅÝÅÝÅÅÐò¡¢¿ìËÙÅÅÐò£©£»
*
3.
Ñ¡ÔñÅÅÐò£¨Ö±½ÓÑ¡ÔñÅÅÐò¡¢¶ÑÅÅÐò£©£»
  ......
/**
* ±£ÁôÁ½Î»Ð¡Êý
* @param d
* @return
*/
private static double remainTwoNumbers(double d){
java.math.BigDecimal f1 = new java.math.BigDecimal(d);//СÊýµãºó±£Áô2Î ......
±¨Îļø±ðÔÚÉí·ÝÈÏÖ¤ÖÐÕ¼ÖØҪλÖã¬ÊÇÈÏ֤ϵͳµÄÒ»¸öÖØÒª»·½Ú£¬ÔÚ½ðÈÚºÍÉÌҵϵͳÖй㷺ӦÓá£
±¨Îļø±ð³£Óñ¨Îļø±ðÂ루Message Authentication Code,¼´MAC£©×÷Ϊ¼ø±ðµÄ»ù´¡£¬
......
Ò»¡¢´Ó¸ù±¾ÉÏÈÏʶjava.lang.StringÀàºÍString³Ø
Ê×ÏÈ£¬ÎÒ½¨ÒéÏÈ¿´¿´StringÀàµÄÔ´ÂëʵÏÖ£¬ÕâÊÇ´Ó±¾ÖÊÉÏÈÏʶStringÀàµÄ¸ù±¾³ö·¢µã¡£´ÓÖпÉÒÔ¿´µ½£º
1¡¢StringÀàÊÇfinalµÄ£¬²»¿É±»¼Ì³Ð¡£public final class String¡£
2¡¢StringÀàÊǵı¾ÖÊÊÇ×Ö·ûÊý×échar[], ²¢ÇÒÆäÖµ²»¿É¸Ä±ä¡£private final char value[];
È»ºó´ò¿ªStr ......