Java beginners must read - experience summary

xiaoxiao2021-03-06  18

A nice stuff, put it here :) 1: JDK Development System Environment Variable Settings: Win2000: Right-click My Computer - "Properties -" Advanced - "Environmental Variable ClassPath = JDK installation / libpath = jdk installation directory / bin Note: must not be ignored ".". Win98: Modifying AutoCexe.bat is to modify the automatic batch file. Add: set classpath = .; JDK installation / libset path = jdk installation directory / bin;% PATH% 2: (premise settings system environment variable) Do not bring compilation, quite simple: Javac class name .javajava class name About the compilation problem of bag: If your class is packaged, you should compile: Javajava's parent catalog. Javajava package name. Class name 3: Tomcat server configuration: 1): Set the system Environment variable. 2): java_home = g: /jbuilder6/jdk1.3.1 g: /jbuilder6/jdk1.3.1 is a JDK installation directory 3): Tomcat_Home = Tomcat installation directory 4: Modify the Serlet without restart Tomcat modification% Tomcat_Home% / conf / server .xml is approximately as follows: where reloadable is configured to automatically reload, set it to true, if this is not on.

5: Modify the servlet in WebShpere without restarting the service: Modify ../web-inf below Web.xml: Join where reloadInterval =" 3 "reloadingEnabled =" true "fileServingEnabled =" true "directoryBrowsingEnabled =" true "serveServletsByClassnameEnabled = "true" is the main, reloadinterval = "3" reloadingenabled = "true" is to automatically reload 3 seconds after modification. 6: Configure JBuilder6 WebShpere4.0ae, in fact, JB7 can refer to: first install J2EE, then add J2EE to the JB of Libraries. The method is as follows 1 :) Tools ---> configure libraries -> new ---> name: Fill in J2EE, location: The default is old. ----> Add -> Select the J2EE installation path, select the lib folder - OK - OK. 2 :) Return to Configure Libraries, select Required Libraries -> Add - "Select you. J2EE created, you can click OK. Then configure the WebShpere application server and Database Pilot: The first step: Tools -> Enterprise Setup -> Application Servers Set the installation path and the IBM's Java path, DB2 you look at your second step: Project -> Defaults Project Properties Servers Select WS4.0 and should be able to use WebShpere4.0 does not support EJB2.0, WebShpere5.0 support.

Configuring Database Pilot Step 1: Add Category Library Tools -> Config Libraries Add Your Database Driver Table 2: Tools -> Enterprise Setup -> Database Drivers Add the class library you just added to the third step : After restarting JBilder, Tools -> DATABASE PILOT -> Option -> Drivers, add driver Step 4: New construction in Database Pilot Point, Driver: com.ibm.db2.jdbc.app.db2driver.

URL: JDBC: DB2: DB_SDBC. (DB_SDBC is a DB2 database on the server). 7: Solve Java Chinese issues: For Applet and AWT: 1 :) font f = new font (uiResource.getstring ("default_font", font. Plain, 12); UIManager.Put ("label.font", f); uimanager.put ("label.Foreground", color.black; uimanager.put; uimanager.put "Menu.font", f); uimanager.put ("MenuItem.font", f); uimanager.put ("list.font", f); UIManager.put ("Checkbox.Font", F); UIManager. PUT ("Radiobutton.font", F); UIManager.Put ("ComboBox.Font", F); UIManager.put ("TextArea.font", F); 2 :) font f = new font ("Lishu", Font.Plain, 15); UIManager.Put ("Button.Font", Font); UIManager.put ("ToggleButton.Font", Font); UIManager.put ("Radiobutton.Font", Font); UIManager.put "Checkbox.Font", font; uimanager.put ("colorchooser.font", font); UIManager.put ("ToggleButton.font", font); UIManager.Put ("ComboBox.Font", font); UIManager. PUT ("ComboBoxItem.font", font; uimanager.put ("INTERNALFRAME.TILEFONT", FONT); UIManager .put ("label.font", font; uimanager.put ("list.font", font); uimanager.put ("menubar.font", font); UIManager.put ("menu.font", font) UIManager.Put ("MenuItem.Font", Font; UIManager.Put ("RadiobuttonMenuItem.font", FONT); UIManager.put ("CheckBoxMenuItem.font", font); uimanager.put ("PopupMenu.font", Font); UIManager.Put ("Optionpane.Font", font); UIManager.put ("Panel.Font", font); UIManager.put ("ProgressBar.font", Font);

UIManager.put ("scrollpane.font", font); UIManager.put ("ViewPort", font); UIManager.put ("Tabbedpane.Font", Font); UIManager.put ("TableHeader.Font", font); UIManager.put ("textfield.font", font; uimanager.put ("passwordfiled.font", font); UIManager.put ("textarea.font", font); UIManager.put ("TextPane.Font", font ); UIManager.Put ("editorpane.font", font); UIManager.put ("TitledBorder.font", font); UIManager.put ("Toolbar.Font", Font); UIManager.put ("Tooltip.Font" , UIManager.Put ("Tree.Font", Font); 3 :) For JSP and Servlet: Solution: First: Add: <% @ Page ContentType = "TEXT / HTML; Charset = GB2312 "%> servlet or inside public void doGet (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {response.setContentType (" text / html; charset = gb2312 "); // this is important if the above not to use The following method is called before the data is stored: public static string unicodetochinese (string s) {{if (s == null || s.equals (")) returno" "; string newstring = null; newstring = new String (S.GetBytes ("ISO8859_1"), "GB2312"); return newstring;} catch (UnsupportedEncodingException e) {return s;}} public static String ChineseToUnicode (String s) {try {if (s == null || s.equals ( "")) return ""; String newstring = null Newstring = new string (S.GetBytes ("GB2312"), "ISO8859_1"); return.comtring;} catch (unsupporteencodingexception e) {return s;}} 3 :) Solve WebLogic / WebShpere Chinese Question: In Web.xml File The Chinese environment is required.

R As: WebLogic.httpd.inputcharset ./* GB2312 4:) JavaMail Accessories Chinese garbled: / * @ @ @ @ 8 8 8 编 编 编 文件 文件 8 名 8 编 过程 编 编 编 编 编 编 编 编 编 编 编 编 编 编 编 编 编 编 编 编 编 编 编 编 编 编 编 编 编 编 编 编 编 编 编 编 编 编 编 编) {// Set a flag, determine that the file name is obtained from Content-Disposition or from Content-Type to get boolean flag = true; if (body == null) {Return null;} String [] cdis; try {cdis = Body.getHeader ("Content-Disposition");} catch (Exception E) {Return Null;} if (cdis == null) {flag = false;} if (! flag) {Try {CDIS = body.getHeader (" ");} CatCH (Exception e) {return null;}}}}} (cdis == null) {return null;} if (cdis [0] == null) {Return Null;} // From Content- DISPSITION Get the file name IF (FLAG) {INT POS = CDIS [0] .indexof ("filename ="); if (pOS <0) {return null;} // If the file name is quoted IF (CDIS [0] .Charat (CDIS [0 ] .length () - 1) == '") {Return CDIS [0] .substring (POS 10, CDIS [0] .length () - 1);} Return CDIS [0] .SUBSTRING (POS 9, CDIS [0] .length ());} else {INT POS = CDIS [0] .indexof ("name ="); if (pOS <0) {Return NULL;

} // If the file name is quoted IF (CDIS [0] .Charat (CDIS [0] .length () - 1) == '"') {Return CDIS [0] .substring (POS 6, CDIS [0 ] .length () - 1);} Return CDIS [0] .substring (POS 5, CDIS [0] .length ());}} 8: String Split: Public int getCount (String Str, String Sign) {// Find a number of Strs in a string, a number of occurrences of a specific substring S (Str == null) return 0; StringTokenizer S = New StringTokenizer (STR, SIGN); Return S.CountToKens ();} public string [ ] GetArray (String Str, String Sign) {// is marked by a specific substring S, the sub-string is intermediary. INT count = getcount (str, sign); int J = 0; string [] arr = new string [ Count]; for (int i = 0; i

1.3 solve a problem as follows: public String stringReplace (String sourceString, String toReplaceString, String replaceString) {String returnString = sourceString; int stringLength = 0; if (toReplaceString = null!) {StringLength = toReplaceString.length () } If (returnstring! = Null && returnstring.LENGTH ()> StringLength) {int max = 0; string s4 = ""; for (int i = 0; i SourceString.Length ()? SourceString.Length (): i stringLength; string s3 = sourceString.Substring (i, max); if (! s3.equals (toreplacstring)) {s4 = s3 .SUBSTRING (0, 1);} else {S4 = ReplaceString; i = StringLength -1;}} returnstring = S4;} Return Returnstring;} 9: Setting WebLogic connection pool: Pool configuration: Suppose configured services: ExpServ and database server machine names: ExpServ database SID: EXPSERVSID, username, and password are: ExpServ as an example of WebLogic 7.0, first start service http: // localhost: port / console Open Service / JDBC / Connection Pools Configure O raclePool follows: Configuration: Name: oraclePool URL: jdbc: oracle: thin: @expserv: 1521: expservSID Driver Classname: oracle.jdbc.driver.OracleDriver Properties (key = value): user = expservTargets: Targets-Server: expserv in weblogic7 In addition to the database password in .0, other Pool parameters can be directly modified directly in Config.xml.

10: Digital Transfer Currency Capital (JS) Function Changetobig (Value) {Var Intfen, I; Var Strarr, Strnum, Strfen, Strdw, Strnum, Strbig, Strnow; IF (TRIM (Value) == "") // Data is Returns "zero" return "zero" illegal prompt when it is illegal, and returns the empty string {strr = "data" value "illegal!" "; } StrCheck = value "."; Strr = strcheck.split ("."); StrCheck = strarr [0]; if (strCheck.Length> 12) // data is greater than or equal to 10 trillion tips Unable to handle {streyr = " Data " Value " excessively, unable to handle! "Alert (strerr); return";} try {i = 0; strbig = "; intfen = value * 100; // Convert To divide the numerical STRFEN = intfen.tostring (); strarr = strfen.split ("."); strfen = strarr [0]; intfen = strfen.Length; // Get length strr = strfen.split (""); // Take each value Decompose to the array inside the While (INTFEN! = 0) // Decomposition and conversion = i 1; switch (i) // selection unit {case 1: strdw = "points"; Break; case 2: strdw = "angle "; Break; Case 3: strdw =" yuan "; Break; case 4: strdw =" pick "; break; case 5: strdw =" "; break; case 6: strdw =" 仟 "; Break; Case 7 : strdw = "10,000"; Break; Case 8: strdw = "Pick"; BREAK; Case 9: strdw = ""; Break; case 10: strdw = "仟"; Break; Case 11: strdw = "hundreds"; Break; Case 12: strdw = "pick"; break; casse 13: strdw = "佰"; break; casse 14: strdw = ""; Break;} Switch (strarr [intfEN-1]) // Select Number {CASE "1": Strnum = "壹"; Break; Case "2": strnum = "";

Break; Case "3": Strnum = "叁"; Break; Case "4": strnum = ""; break; case "5": strnum = "Wu"; Break; Case "6": strnum = " "; Break; Case" 7 ": strnum =" 柒 "; break; case" 8 ": strnum =" 捌 "; break; case" 9 ": strnum =" 玖 "; break; case" 0 ": strnum = "Zero"; break;} // handle special case strnow = strbig.split (""); // Divided into zero case IF ((i == 1) && (strarr [intfen-1] == "0 ")) Strbig =" whole "; // angle is zero-when ELSE IF ((i == 2) && (strarr [INTFEN-1] ==" 0 ")) {// At the same time zero Situation IF (strbig! = "Whole") strbig = "zero" strbig;} // yuan is zero case ELSE IF ((i == 3) && (strarr [intfen-1] == "0") Strbig = "Yuan" strbig; // Pick up - 且 ELSE IF ((i <7) && (i> 3) when it is zero and the previous one (yuan or more) is not zero && (Strarr [INTFEN-1] == "0") && (STRNOW [0]! = "zero") && (Strnow [0]! = "yuan")) Strbig = "zero" strbig; // Pick up - 中 一 且 且 且 e e e i i (i ((i ((情况 情况 (((情况 零 (零 为 零 零 为 情况 为 为 为 为 为 零 为") && (STRNOW [0] ==" zero ")) {} // Pick up - 仟 中 位 且 e 且 e e e e ELSE IF ((i <7) && (i> 3) && (strrr [intfEN-1] == "0") && (Strnow [0] == "yuan"))) {} // When 万 万 万 上 上 (((( i == 7) && (strarr [intfEN-1] == "0")) Strbig = "10,000" S TRBIG; // Pick up 10,000,000 in a zero and the previous one (10,000 or more) is not zero, ELSE IF ((i <11) && (i> 7) &&

(strarr [intfEN-1] == "0") && (Strnow [0]! = "zero") && (Strnow [0]! = "10,000")) Strbig = "zero" strbig; // Pick up Wan - Ten thousand sizes is zero and the previous one (more than 10,000) is also across else IF ((i <11) && (i> 7) && (Strarr [INTFEN-1] == " 0 ") && (Strnow [0] ==" Wan ")) {} // Pick up 10,000 in one bit of zero and the previous one is the case of 10,000 and zero (((((( I <11) && (i> 7) && (strrr [intfEN-1] == "0") && (Strnow [0] == "zero")) {} // million is zero and there is a position and When more than 100,000 yuan, ELSE IF ((i <11) && (I> 8) && (Strarr [INTFEN-1]! = "0") && (Strnow [0] == "10,000" ) && (Strnow [2] == "")) Strbig = Strnum strdw "万 零" strbig.substring (1, strbig.length); // separately handle ELSE IF (i == 11) { When the // billion is zero, when there is zero, it will drop the rumor to zero IF ((strnow [intfen-1] == "0") && (Strnow [0] == "10,000") && [2] == "")) Strbig = "100 million" "zero" strbig.substring (1, strbig.length); // billion is zero and there is no need for zero, remove the ELSE IF ((strrr [intfEN-1] == "0") && (Strnow [0] == "10,000") && (Strnow [2]! = "")) Strbig = "100 million" strbig.substring 1, strbig.Length); // billion is not zero and completely zero-existing position, remove the 万 补 ELSE IF ((Strnow [0] == "10,000") && (Strnow [2] == "")) Strbig = strnum strdw "zero" strbig.substring (1, strbig.Length); // billion is not zero and unable to exist, remove Wan else IF ((strNow [ 0] == "10,000") && (STRNOW [2]! = "")) strbig = strnum strdw strbig.substring (1, strbig.length);

// Other normal conditions Else strbig = strnum strdw strbig;} // 补 零 中 中 为 为 且 零 零 不 不 不 ((补 ((((((((((((((((((((( 15) && (I> 11) && (strn [INTFEN-1] == "0") && (Strnow [0]! = "Zero") && (Strnow [0]! = "100 million) Strbig =" Zero " strbig; // pick up ELSE IF when it is zero ((i <15) && (i> 11) && ((i <15) && (i> 11) && ((i <15) && (i> 11) && Strarr [intfEN-1] == "0") && (Strnow [0] == "100 million)) {} // pick up 100 million yuan in zero and the previous one is 100 million and zero Else IF ((i <15) && (I> 11) && (Strarr [INTFEN-1] == "0") && (Strnow [0] == "zero")) {} // 100 million 位 且 且 ((i <15) && (i> 11) && (Strarr [INTFEN-1]! = "0") && (Strnow [0] == "zero") && (Strnow [1] == "100 million") && (Strnow [3]! = "仟")) Strbig = Strnum StrDW strbig.substring (1, strbig .length); // billion is zero and there is 10 million and more than 10 billion times, in 100 million yuan to make up ELSE IF ((i <15) && (i> 11) && (strarr [intfen-1] ! = "0") && (STRNOW [0] == "zero") && (Strnow [1] == "100 million") && (Strnow [3] == "仟")) Strbig = Strnum strDW "billion Zero " strbig.substring (2, strbig.length); Else strbig = strnum strdw strbig; strfen = strfen.substring (0, intfen-1); intfen = strfen.length; strarr = strfen.split (" " );} Catch strbig;} catch (err) {return ""; // Failure is returned to the original value}}} 11: Remove all directories under the folder: / * * Delete all the files under a directory * / public static void deLallFile (String path) {file file = new file (path); if (! File.exists ()) Return;

IF (! file.isdirectory ()) return; string [] templist = file.list (); file temp = null; for (int i = 0; i

String str = "2002.07.04"; paraSeposition POS = new paraSeposition (0); DATE DT = formatter.parse (STR, POS); if (dt! = Null) {// is a legal date} else {// illegal date } 2 :) Two dates are reduced to import java.util. *; Import java.text. *; Class a {public static void main (string [] args) {string s1 = "2003/08/15 17:15: 30 "; string s2 =" 2002/09/14 14:18:37 "; try {simpledateformat formatter = new SimpleDateFormat (" YYYY / MM / DD HH: MM: SS "); Parseposition POS = New PaSeposition (0); PARSEPSITION POS1 = New PaSeposition (0); DATE DT1 = Formatter.Parse (S1, POS); DATE DT2 = Formatter.Parse (S2, POS1); System.out.Println ("DT1 =" DT1); System.out .println ("DT2 =" DT2); long L = dt1.gettime () - DT2.Gettime (); System.out.Println ("Hello World! =" L);} catch (Exception E) {system .out.println ("exception" e.tostring ());}}} 3 :) Get 2 months later: Import java.util. *; import java.text.dateFormat; public class test2 {public static void main (string args []) throws exception {string Date = "2001/11/30"; DateFormat DA teFormat = DateFormat.getDateInstance (DateFormat.MEDIUM); GregorianCalendar grc = new GregorianCalendar (); grc.setTime (new Date (date)); grc.add (GregorianCalendar.MONTH, 2); System.out.println ( "grc = " dateFormat.format (grc.getTime ()));}} 13: jsp / servet redirects: do not change the url: 1:) servlet: public void doGet (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { GetServletContext (). getRequestDispatcher (Test2URL) .forward (Request, Response); 2: JSP Change the URL: 1:) Response.sendRedirect (" / Web / Mail / Pop3.jsp "); 14: JB7 WebLogic6.x configuration method as follows: Win 2000 Temp, TMP Configuration Because we generated EJB related code To make a series of compilation, then the generated temporary file must be placed, but the TEMP in Win2000, the TMP directory is equipped with spaces such as% UserProfile% / Local Settings / Temp, let's configure: 1) Right-click "My Computer" selection attribute, select "Advanced" in the pop-up dialog box, then select "Environment Variable" button, 2) Modify "Administrator's user variable" and " The TEMP, TEMP, TMPDIR options in system variables, click Each option, then click "Edit" (right), change each variable name TEMP, TEMP, TMPDIR to C: / Winnt / Temp Of course, this is not a must, but I suggest you do this. In fact, it is not difficult. If you finish it, then the win2000 environment should have no problem. Weblogic 6.x part, JDBC Connection Pool configuration With mysql small database Example Before performing this configuration, let's put the database JDBC driver JAR file to the D: /bea/wlserver6.1/lib/jdbc (suggest this, there is no JDBC directory to build a), then edit The StartWeblogic.cmd file under /befig/mydomain, add the JDBC driver file of the database in ClassPath, such as red word part:: runweblogicecho overset path =. / Bin ;/ bin / oci817_8; d: / oracle / ora81 / bin;% path% set classpath =. / lib / cr_wls60f.jar ;./ lib / weblogic_sp.jar; ./ lib / weblogic.jar; ./ lib / jdbc / mysql.jar like WebLogic startup The database JDBC driver that will only be loaded, the configuration will be normal, otherwise it will report an error. 1) Click Co in the WebLogic console. Nfigure a new JDBC Connection Pool ... 3) Fill in each parameter, the results are as follows: URL: JDBC: mysql: //127.0.0.1: 3306 / TestDriver classname: Org.gjt.mm.mysql.driverproperties (key = Value): User = root4) Don't forget to add Apply to apply:) 5) The initial capacity, maximum capacity, capacity growth, etc., which can be signed, can be configured according to the requirements of the need to configure 6), we The above configuration work has not really applied to WebLogic, so it's just a step, select the Targets check, select the Servers check, select MyServer in Available, then "->", then click Apply Apply.

This way that we do will really be actually effective. WebLogic will only know the JDBC Connection Pool II. Configuring Data Source 1) In the WebLogic Console, use the Services / JDBC / TX Data Sources2 in turn.) Click Configure A New JDBC TX. Data Source ... 3) Fill in each parameter, as follows: JNDI Name: MySQLDataSorucePoolName: MySQLPoolrow Prefetch Size: 48Stream Chunk Size: 2564) Don't forget to apply :) 5) Similarly, choose Targets , Select the Servers check, select MyServer in Available, then click "->", then click Apply. This way that we do will really be actually effective, and WebLogic will only know the DataSource we have configured. JBUILDER 7 related configuration 1. Lame as WebLogic, before performing this configuration, put the database JDBC driver JAR file in the D: / jbuilder7 / lib / jar file (suggesting this, no JDBC directory to build a) 1) Open JBuilder 7, click Tools / Enterprise Setup ....... 2) Select the Database Drivers Sign 3 in the pop-up window) Point Add button, pop up a new window (maybe you Slightly different from the graph) 4) Click the New ... button, pop up a new window, and change the Name: The default value is mysql (as long as it makes sense, what is all the names) 5) Click Add. .. button to find and add a database of JDBC driver, of course, we go to D: / jBuilder7 / lib / jdbc, choose mysql.jar, pay attention, don't expand mysql.jar, select the picture, then press OK. . Tip: You can match the SHIFT and CTRL keys to select multiple .jar files. 6) The result is as follows, if there is a plurality of .jar files that need to be added, you can also click the Add ... button to continue adding. 7) OK exit .8) OK, then MySQL JDBC driver has been added. 9) OK again, JBuilder prompts to restart, the above configuration will take effect, determine and restart JBUILDER. Second, the configuration of EJB 2.0 and application servers, with WebLogic 6.x as an example to install Borland Enterprise Servler 5.02 before doing this configuration, IAS 4.5 is also a matter, both of them, of course, I am new. Old, installation procedure, because it is very easy! Basically, I will install my installation in D: / BorlandEnterpriseserver.

1) Open JBuilder 7, click Tools / Enterprise Setup ....... 2) Select the CORBA sign, drop-down list box under Configuration, select Visibroker 3) Select Edit ..., pop-up Edit Confiuration window Click Path for ORB Tools 4) Click Path for ORB Tools: Browse the ... Browse button, pop up the Select Directory window, select D: / BorlandEnterpriseServer5 / bin and OK. 5) Two times, OK, JBuilder asked you to restart, no way, do it, restart JBuilder. 6) After restart, go to Tools / Enterprise Setup ......., choose CORBA item, select Edit, select Library for Projects next to the pop-up window ... button 7) User in the new window in the pop-up You will find more options Borland Enterprise Server 5.0.2 Client, which is displayed in the picture, and then exits three times ok. 8) Select Project / Default Project Properties item 9) Select a Server sign in the dialog box, click ... Buttons, 10) In the new dialog box that pops up, select WebLogic Application Server 6.x , then Check if enable server, see the red box in the figure. 11) After checking Enable Server, other optional or detailed, click ... buttons, select Home Directory; select Working Directory; for your machine's WebLogic location. 12) Click on the Add button in the Class sign, add it to the D: /Bea/wlserver6.1/lib/cr_wls60f.jar file. As shown in the red line above. Use the MOVE UP button to move the D: /bea/wlserver6.1/lib/cr_wls60f.jar file, because generally added .jar files at the bottom side. This step is also more important, because WebLogic can be launched directly in the JBuilder environment, then it is necessary to test whether License is legal, that is, the cr_wls60f.jar file exists. 13) Select the Custom check, configure it as shown in the following red line, may have a different WebLogic directory location to have me, but it is the same. After configuring, click the OK button to exit Domain Name: MyDomain Server Name: MyServer Version: 6.1 Service Pack1 (D: /Bea/WLSer6.1) 14) Single Server for All Services in Project drop-down list box in the picture window Select WebLogic Application Server 6.x as shown, then OK exits.

15) When this JBuiler 7 is completed with WebLogic 6.x, then let's start! 15. Calculate the date period PUBLIC INT GETDAYS (Date SD, DATE ED) {Return (Ed.getTime () - SD.getTime ()) / (3600 * 24 * 1000)} 16. Date Add or decrease SimpleDateFormat SDF = New SimpleDateFormat "yyyymmdd"); string str = "20011230"; DATE DT = SDF.PARS (Str, New PaSeposition (0)); Calendar RightNow = Calendar.GetInstance (); RightNow.SetTime (DT); RightNow.Add (Calendar. Date, 2); // Date you have to add Date DT1 = rightnow.gettime (); string restr = sdf.format (dt1, ", new fieldPosition (0)); System.out.Println (restr); 17. Time display control first way: getting system time </ title> </ head> <body> <% java.util.date date = new java.util.date () ;%> Now: <% = DATE%> </ body> </ html> Run results: Tue Jul 31 10:32:52 CST 2001 second way: <% @ Page Import = "Java. Util. *, java.text. * "%> <html> <head> <title> Display Current time </ title> </ head> <body> Current time: <% DATE NOW = New Date (); OUT. Println (Dateformat.gettimeInstance (). format (now));%> </ body> </ html> Run Results: 10:31:42 AM third way: <% java.text.SIMPLEDATEFORMAT FORMATTER = New Java. Text.SIMPLEDATEFORMAT ("YYYY Year MM Moon DD Day"); java.util.date currentTime_1 = new java.util.date (); o Ut.print (currentTime_1));%> Run results: July 31, 2001: <% java.text.SIMPLEDATEFORMAT formatter = new java.text.SIMPLORMAT ("YYYY / MM / DD HH / mm / s "); java.util.date currenttime_1 = new java.util.date (); out.print (formatter.format (currentTime_1)));%> Run Results: 2001/07/31 10/32 / 52 Third four ways is actually the same, he can generate a thousand variable format.</p> <p>18. Encryption & Decryption When the string STR is encrypted before inserting the database: java.net.urlencoder.Encode (String Str); decoding again when removed from the database: (You can do not encrypt, only decode, try it; No re-encryption) java.net.urdecoder.decode (String Str); 19. Page refresh: There are three ways: 1, add: <title> xxxxx </ title> Add below! Timed refresh: <meta http-equiv = "refresh" content = "10; URL = http: // ourselves> 10 represents refresh interval 2.jsp <% response.setheader (" refresh "," 1 "); %> Nothing to refresh once 3. Use JavaScript: <script language = "javascript"> setTimeout ("Self.Location.Reload ();", 1000); <script> once 20. Print: 1. Direct call Windows function <input type = "innclick =" οnclick = "οnclick =" window.focus (); window.print () "> 2. Call JS // Put between Head and Head <script language = javascript> <script language = javascript> < ! - function setprint () {wb.execwb (8, 1);} function previewPrint () {wb.execwb (7, 1)} // -> </ script> // Between Body and Body <OBJECT classid = CLSID: 8856F961-340A-11D0-A96B-00C04FD705A2 height = 0 id = WB width = 0> </ OBJECT> <INPUT type = "button" value = "Print Setup" id = button1 name = button1 οnclick = "setprint ();"> <input type = "value =" Print preview "ID = button2 name = button2 οnclick =" previewPrint (); "> 21. Use execl to display the data in the client: <style type = "Text / CSS"> {.showtd {color: # 003366;} .hiddentd {display: none;} .onfocue {color: # cc66ff;} .offfocue {color: # 003366;}} # floater {Left: 445px; Position: Absolute; Top: 15px; Visibility: Visible; Width: 125px; z- INDEX: 10} </ stop> <object classid = "CLSID: 0002E510-0000-0000-C000-000000000046" ID = "</p> <p>Spreadsheet1 "width =" 676 "Height =" 388 "> <parame =" htmlurl "value> <parame =" htmldata "value ="> <parame = "datatype" value = "htmldata"> <parame = "Autofit" value = "0"> <param name = "displayColheaders" value = "- 1"> <parame = "displayGridlines" value = "- 1"> <parame = "displayhorizontalscrollbar" value = "- 1 > <Param name = "displayRowheaders" value = "- 1"> <parame = "displaytitlebar" value = "- 1"> <parame = "displaytoolbar" value = "- 1"> <param name = "DisplayVerticalScrollbar "value =" - 1 "> <param name =" enableautocalculate "value =" - 1 "> <parame =" enableevents "value =" - 1 "> <param name =" mofterreturn "value =" - 1 "> <param name = "MoveAfterReturndirection" value = "0"> <parame = "rightttoleft" value = "0"> <param name = "viewablerange" value = "1: 65536"> </ object> <div class = " HiddENTD "ID =" Tablers "> <Table Width = 95% Align = Center Border = 1 Cellspacing = 0 Cellpadding = 0> <TD> <TD> Customer Name A </ TD> <TD> Customer Name B </ TD> <TD> Customer Name C </ TD> <TD> Customer Name D </ TD> <Tr> <TD> ABC </ TD> <TD> DEF </ TD> <TD> 111 </ TD> <TD> 222 </ TD></p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-56792.html</div><div class="plugin d-flex justify-content-center mt-3"></div><hr><div class="row"><div class="col-lg-12 text-muted mt-2"><i class="icon-tags mr-2"></i><span class="badge border border-secondary mr-2"><h2 class="h6 mb-0 small"><a class="text-secondary" href="tag-2.html">9cbs</a></h2></span></div></div></div></div><div class="card card-postlist border-white shadow"><div class="card-body"><div class="card-title"><div class="d-flex justify-content-between"><div><b>New Post</b>(<span class="posts">0</span>) </div><div></div></div></div><ul class="postlist list-unstyled"> </ul></div></div><div class="d-none threadlist"><input type="checkbox" name="modtid" value="56792" checked /></div></div></div></div></div><footer class="text-muted small bg-dark py-4 mt-3" id="footer"><div class="container"><div class="row"><div class="col">CopyRight © 2020 All Rights Reserved </div><div class="col text-right">Processed: <b>0.036</b>, SQL: <b>9</b></div></div></div></footer><script src="./lang/en-us/lang.js?2.2.0"></script><script src="view/js/jquery.min.js?2.2.0"></script><script src="view/js/popper.min.js?2.2.0"></script><script src="view/js/bootstrap.min.js?2.2.0"></script><script src="view/js/xiuno.js?2.2.0"></script><script src="view/js/bootstrap-plugin.js?2.2.0"></script><script src="view/js/async.min.js?2.2.0"></script><script src="view/js/form.js?2.2.0"></script><script> var debug = DEBUG = 0; var url_rewrite_on = 1; var url_path = './'; var forumarr = {"1":"Tech"}; var fid = 1; var uid = 0; var gid = 0; xn.options.water_image_url = 'view/img/water-small.png'; </script><script src="view/js/wellcms.js?2.2.0"></script><a class="scroll-to-top rounded" href="javascript:void(0);"><i class="icon-angle-up"></i></a><a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"><i class="icon-angle-down"></i></a></body></html><script> var forum_url = 'list-1.html'; var safe_token = 'ERcr_2FUfqsxPmYCryWex0kKczAjkvwnCMmcZ2RDrnN8EJkYRfHx_2B8zcsmSBZQIg2j1cwxUVdP8FNRnVmM'; var body = $('body'); body.on('submit', '#form', function() { var jthis = $(this); var jsubmit = jthis.find('#submit'); jthis.reset(); jsubmit.button('loading'); var postdata = jthis.serializeObject(); $.xpost(jthis.attr('action'), postdata, function(code, message) { if(code == 0) { location.reload(); } else { $.alert(message); jsubmit.button('reset'); } }); return false; }); function resize_image() { var jmessagelist = $('div.message'); var first_width = jmessagelist.width(); jmessagelist.each(function() { var jdiv = $(this); var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width(); var jmessage_width = Math.min(jdiv.width(), maxwidth); jdiv.find('img, embed, iframe, video').each(function() { var jimg = $(this); var img_width = this.org_width; var img_height = this.org_height; if(!img_width) { var img_width = jimg.attr('width'); var img_height = jimg.attr('height'); this.org_width = img_width; this.org_height = img_height; } if(img_width > jmessage_width) { if(this.tagName == 'IMG') { jimg.width(jmessage_width); jimg.css('height', 'auto'); jimg.css('cursor', 'pointer'); jimg.on('click', function() { }); } else { jimg.width(jmessage_width); var height = (img_height / img_width) * jimg.width(); jimg.height(height); } } }); }); } function resize_table() { $('div.message').each(function() { var jdiv = $(this); jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>'); }); } $(function() { resize_image(); resize_table(); $(window).on('resize', resize_image); }); var jmessage = $('#message'); jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); }); jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); }); $('#nav li[data-active="fid-1"]').addClass('active'); </script>