Java beginners must read - experience summary (reproduced)

xiaoxiao2021-03-06  19

The author is always very good

1: JDK Development System Environment Variable Settings: Methods: WIN2000: Right-click My Computer - "Properties -" Advanced - "Environment Variable ClassPath = .; JDK Installer / libpath = JDK Installation Directory / bin : It 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: (Prerequisite to set the system environment variable) Do not compile the bag, quite simple: Javac class name. Javajava class name

About the compilation problem of bag: If your class is packaged, you should compile the following method: Javac -d package, the parent class name. 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 the Java Chinese Question: 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.TITLEFONT", 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; 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", Font; UIManager.put ("Tree.Font", Font);

3 :) For JSP and Servlet: Solution: First: Add: <% @ Page ContentType = "Text / HTML; Charset = GB2312"%> or HttpServletRequest Request, HttpservletRequest Request, HttpServletResponse Response Throws servletexception, ioException {response.setContentType ("text / html; charset = GB2312"); // This is an important above if you don't do it, use the following method before calling before the data is stored: public static string UnicoDetoChinese (String S) {Try {IF (s == null || s.equals (")) return" "; string news = null; newstring = new string (s.getbytes (" ISO8859_1 ")," GB2312 "); Return Newstring;} catch (unsupporteencodingexception e) {return s;}} public static string chinesetounicode (string s) {try {if (s == null || s.equals (")) Return"; string newstring = null; Newstring = new string (s.getbytes), "ISO8859_1"); return.com;} catch (unsupporteencodingexcection e) {return s;}}

3 :) Solve WebLogic / WebShpere Chinese Problem: The Chinese environment is required in the web.xml file.

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

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 (toreplastring)) {s4 = s3.substring (0, 1);} else { S4 = replaceString;}} returbustring = s4;}} returnstring = s4;} Return Returnstring;} 9: Setting WebLogic connection pool: Pool configuration: Assume configured service: ExpServ and database server machine name: ExpServ database SID : EXPSERVSID, username and password are: EXPSERV Take WebLogic7.0 as an example, start the service http: // localhost: port / console Open Service / JDBC / Connection Pools Configuring OraclePool as follows: confi guration: Name: oraclePool URL: jdbc: oracle: thin: @expserv: 1521: expservSID Driver Classname: oracle.jdbc.driver.OracleDriver Properties (key = value): user = expservTargets: Targets-Server: expserv in the weblogic7.0 In addition to the database password, other Pool parameters can be directly modified directly in Config.xml. 10: Digital Transfer Currency (JS) Function Changetobig (Value) {Var Intfen, I; Var Strarr, Strnum, Strfen, Strdw, Strnum, Strbig, STRNOW;

If (value) == "" // data returns "zero" Return "zero" 非 (isnan) // data illegal prompt, return to the air string {strerr = "data" Value "illegal!" Alert (strerr);} strCheck = value "; strCheck = strCheck.split (". "); strCheck = strarr [0]; if (strCheck.length> 12) / / Data is greater than or equal to 1 trillion, prompts to handle {strerr = "data" value "excessively, unable to handle!" Alert (strr); return ";} try {i = 0; strbig ="; intfen = Value * 100; // Convert to the value of the unit strfen = intfen.tostring (); strarr = strfen.split ("."); strfen = strarr [0]; intfen = strfen.length; // Get the length strarr = strfen.split ("); // Decompose each value into the While (INTFEN! = 0) // Decomposition and conversion {i = i 1; switch (i) // selection unit {casse 1: STRDW = "分"; 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; casse 11: strdw = "hundreds"; Break; case 12: strdw = "pick"; Break; Case 13: strdw = ""; Break; case 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 = "

"Break; Case" 6 ": Strnum =" Lu "; Break; Case" 7 ": strnum =" 柒 "; break; case" 8 ": strnum =" 捌 "; break; case" 9 ": strnum = ""; Breaf; case "0": strnum = "zero"; Break;}

// Test a special case strnow = strbig.split (""); // Divided into zero-when IF ((i == 1) && (strr [intfen-1] == "0")) Strbig = " "; 为 时 情况 e i ((i == 2) && (Strarr [INTFEN-1] ==" 0 "))) {// Amount for zero (strbig! = "Whole") strbig = "zero" strbig;} // yuan is zero case ELSE IF ((i == 3) && (strarr [intfEN-1] == "0")) Strbig = "Yuan" Strbig; // Pick up - 中 且 且 零 零 零 零 零 零 零 零 零 零 零 (((i i)-) 补 ((i <7) && (i> 3) && (Strarr [intfen-1) ] == "0") && (STRNOW [0]! = "Zero") && (Strnow [0]! = "Yuan")) Strbig = "zero" strbig; // Pick up - 中 中 位And the previous one (element or more) is also zero, crossing ELSE IF ((i <7) && (I> 3) && (Strarr [INTFEN-1] == "0") && (STRNOW [0 ] == "zero")) {} // Pick up - 中 中 且 且 e i 过 跨 ELSE IF ((i <7) && (i> 3) && (i <7) && (i> 3) && (strarr [intfEN-1] == "0") && (STRNOW [0] == "yuan")) {} // When 万 万 万 万 ((i == 7) && Strarr [INTFEN-1] == "0")) Strbig = "10,000" strbig; // Pick up 10,000,000 in a zero and the previous one (more than 10,000) is not zero Else IF ((i <11) && (I> 7) && (strrr [INTFEN-1] == "0") && (Strnow [0]! = "zero") && (Strnow [0]! = "10,000 ")) Strbig =" zero " strbig; // Picking up 10,000,000 in a zero and the previous one (10,000) also crosss ELSE IF ((i <11) && I> 7) && (strrr [intfEN-1] == "0") && (strnow [0] == "10,000)) {} // 拾 万 - 中The bit is zero and the previous one is 10,000 and zero. Else IF ((i <11) && (i> 7) &

& (strr [intfEN-1] == "0") && (Strnow [0] == "zero")) {} // million is zero and there is a position and more than 100,000 times, Else IF ((i <11) && (i> 8) && (strr [INTFEN-1]! = "0") && (STRNOW [0] == "10,000") && (Strnow [2] == "仟 ")) Strbig = Strnum StrDW " 10 零 " strbig.substring (1, strbig.length); // separately handle ELSE IF (i == 11) {/ / billion bits of zero When there is a position, go out to zero IF ((strnow [INTFEN-1] == "0") && (STRNOW [0] == "10,000") && (Strnow [2] == "")) Strbig = "100 million" "zero" strbig.substring (1, strbig.Length); // billion is zero and the full zero does not exist, remove the Else IF ((strarr [intfen-1] = = "0") && (STRNOW [0] == "10,000") && (Strnow [2]! = "仟")) Strbig = "100 million" strbig.substring (1, strbig.length); // billion When the position is not zero and the full zero, it will be lost to zero else if ((strNow [0] == "10,000") && (Strnow [2] == "仟") Strbig = Strnum strDW "Zero" strbig.substring (1, strbig.Length); // billion is not zero and unpredictable, removes Else IF ((strNow [0] == "10,000") && STRNOW [2]! = "")) Strbig = Strnum StrDW strbig.substring (1, strbig.Length); // Other normal conditions Else strbig = strnum strdw strbig;} // pick up billion - million billion The middle one is zero and the previous one (i <15) && (i> 11) && (strata) & quin (I <15) && (i> 11) && (strarr [intfen-1] == "0") && (STRNOW [0]! = "zero") && (STRN OW [0]! = "100 million")) Strbig = "zero" strbig; // picks up ELSE IF when it is zero, the previous one (hundred million) is also zero ((i <15) && (i> 11) &&

(strarr [intfEN-1] == "0") && (STRNOW [0] == "100 million")) {} // pick up 100 million yuan in zero, the previous one is 100 million ((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 " Zero " strbig.substring (2, strbig.Length); Else strbig = strnum strdw strbig; strfen = strfen.substring (0, intfen-1); intfen = strfen.length; strarr = strfen.split (" ");} Return strbig;} Catch (err) {return" "; // Returns the original value} 11: Remove all directories under the folder: / * * Delete all the files in a directory * / public Static void deLallFile (String Path) {file file = new file (path); if (! file.exists ()) return; if (! file.Indirectory ()) return; string [] templist = file.list (); File Temp = NULL; for (int i = 0; i

1 :) SimpleDateFormat Formatter = New SimpleDateFormat ("YYYY.MM.DD"); // Find to 2002.07.04 is illegal. 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 DateFormat = 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 Redirection Problem: 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 URL: 1:) Response.sendRedirect (" /Web/mail/pop3.jsp" "etc14 :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 is There is a place to put it, but the TEMP in Win2000, the TMP directory is equipped with spaces such as% UserProfile% / local settings / temp, let's configure it:

1) Right-click "My Computer" selection attribute, select "Advanced" in the pop-up dialog box, then select the Environment Variable button,

2) Modify the TEMP, TEMP, TMPDIR options in "Administrator" and "System Variable", click Each option, then "Edit" (right), name TEMP, TEMP, TMPDIR The value is changed to C: / Winnt / Temp, of course, this is not necessary, just I suggest you do this.

In fact, it is not difficult. If it is finished, the win2000 environment should have no problem. WebLogic 6.x section

First, the JDBC Connection Pool configuration is used as an MYSQL small database.

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 D : /Bea/wlserver6.1/config/mydomain under the StartWeblogic.cmd file, add the JDBC driver file of the database in the ClassPath, such as red word:

: 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

In this way, WebLogic will only load the database JDBC driver used, and the configuration will be normal, otherwise the error will be reported. 1) Expand Services / JDBC / Connection Pools2 in the WebLogic console) Click Configure a New JDBC Connection Pool ...

3) Fill in each parameter, as follows: URL: JDBC: mysql: //127.0.0.1: 3306 / TestDriver classname: org.gjt.mm.mysql.driverproperties: user = root4) Don't forget I have added Apply to apply:) 5) The initial capacity, maximum capacity, capacity growth, and the like, can be configured according to the need to configure 6), and the above configuration work has not really true. Apply to WebLogic, so actions are one step, choose the Targets sign, select the Servers check, select MyServer in Available, then click "->", 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, the result is as follows:

JNDI Name: MySQLDataSorucePoolName: MySQLPoolrow Prefetch Size: 48Stream Chunk Size: 2564) Don't forget to apply Apply to apply :) -> ", then apply any apply. This way that we do will really be actually effective, and WebLogic will only know the DataSource we have configured.

Configuration of JBuilder 7

I. Database driver loading

Like WebLogic, before performing this configuration, first put the database JDBC JAR file to the D: / jbuilder7 / lib / jdbc directory (suggest this, there is 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 the Add button, pop up a new window (maybe you can have a slightly different) 4) Click the New ... button, pop up a new window, and change Name : The default value is mysql (as long as it makes sense, what is the name) 5) Click the Add ... button to find and add the JDBC driver that adds the database, of course, we go to D: / jbuilder7 / lib / jdbc Looking, choose mysql.jar, pay attention, don't expand mysql.jar, and select OK as the image. 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, as an example of WebLogic 6.x

To install Borland Enterprise Servler 5.02 before this configuration, IAS 4.5 is also a matter, both of them, of course, I have a new unused, installation process, because I installed it very easy! Basic is all the way back Car, I put my installation under D: / BorlandEnterpriseserver. 1) Open JBUILDER 7, click Tools / Enterprise Setup .......

2) Select the CORBA sign, drop down the 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: Side ... 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 day 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); // You have to decrease 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</p> <p>The second way: <% @ page import = "java.util. *, Java.text. *"%> <Html> <head> <title> Show 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</p> <p>The third way: <% java.text.SIMPLEDATEFORMAT formatter = new java.text.SIMPLEDATEFORMAT ("YYYY Year MM Month Day"); java.util.date currentTime_1 = new java.util.date (); out.print (Formatter.Format (CurrentTime_1));%> Run results: July 31, 2001</p> <p>The fourth way: <% java.text.SIMPLEDATEFORMAT formatter = new java.text.SIMPLEDATEFORMAT ("YYYY / MM / DD HH / MM / SS"); java.util.date currentTime_1 = new java.util.date () Out.print (currenttime_1));%> Run results: 2001/07/31 10/32/52 Third four ways actually the same he can generate a variable format. 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);</p> <p>19. Page refresh: There are three ways: 1. Set it in HTML: <title> XXXXX </ TITLE> Add below! Timed refresh: <meta http-equiv = "refresh" content = "10; URL = http: // 自 自己"> 10 represents refresh interval</p> <p>2.jsp <% response.setHeader ("refresh", "1");%> No one second to refresh once</p> <p>3. Using JavaScript: <script language = "javascript"> setTimeout ("Self.Location.Reload ();", 1000); <script> one second</p> <p>20. Print: 1. Call the Windows function directly <input type = "button" value = "οnclick =" window.focus (); window.print () "></p> <p>2. Call JS // Put in Head and Head <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 Settings" ID = Button1 Name = Button1 οnclick = "setPrint ();> <input type =" button "value =" Print Preview "id = Button2 name = button2 οnclick =" previewprint (); "</p> <p>21. Put 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></p> <p><Object classid = "CLSID: 0002E510-0000-0000-C000-000000000046" ID = "spreadsheet1" width = "676" height = "388"> <param name = "htmlurl" value> <parame = "htmldata" Value = ""> <Param name = "datatype" value = "htmldata"> <parame = "autofit" value = "0"> <parame = "displaycolheaders" value = "- 1"> <parame = "DisplayGridLines "Value =" - 1 "> <param name =" Displayhorzontalscrollbar "value =" - 1 "> <param name =" displayRowheaders "value =" - 1 "> <parame =" displaytitlebar "value =" - 1 "> <param name = "displaytoolbar" value = "- 1"> <parame = "displayverticalscrollbar" value = "- 1"> <parame name = "enableautocalculate" value = "- 1"> <parame = "enableevents" VALUE = "- 1"> <parame = "moveafterreturn" value = "- 1"> <param name = "moveafterretuntirection" 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> <TR> <TD> Custom Name A </ TD> <TD> Custom Name B </ TD> <TD> Customer Name C </ td> <TD> Customer Name D </ TD> <Tr> <TD> ABC </ TD> <TD></p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-41413.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="41413" 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.041</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 = 'rLSGcZriyxppT9N0wFS_2BBY1yhW3bHAT8h3LvbH7zefoXUgwLjYWOP9Rw31cJX8VmYXHTAva3hGwl_2B0gX5_2Bdqsg_3D_3D'; 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>