A method of using xml+xsl to quickly generate common code for a large number of JSPs.
Last Update:2017-02-28
Source: Internet
Author: User
Js|xml uses the Xml+xsl method of quickly generating a large number of JSP common code . Reference JBuilder servlet Wizard to use xml+xsl to generate JSP common code. XML sample: <?xml version= "1.0" encoding= "GB2312" ><?xml-stylesheet "type=" text/xsl "href="? ><jsp xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance" xsi:nonamespaceschemalocation= "jspsrcgen.xsd" > <param> <variable>rloginusername</variable> <name> Loginusername</name> <type>string</type> <src>request</src > <default>lizongbo</default> <desc> User's login name </desc> </ Param> <param> <variable>clastlogintime</variable> <name >lastlogintime</name> <type>long</type> <src>cookie</src > <default>0</default> <desc> user's last logon time </desc> </ Param> <param> <variable>suserpass</variable> <name>userpass</name> <type>string</ type> <src>session</src> <default>password</default> <desc> stored in the session password </desc> </param></jsp> xsl file slightly. the conversion of the effect diagram and related code: testjsp.jsp variable Name argument name variable type variable source default value note Rloginusernameloginusernamestringrequestlizongbo User's login name Rloginusernameloginusernamestringre Questlizongbo User's login name Rloginusernameloginusernamestringrequestlizongbo user's login Suserpassuserpassstringsessionpassword stored in session In the password Suserpassuserpassstringsessionpassword stored in the session password Suserpassuserpassstringsessionpassword stored in the session password Clastlogintim ELASTLOGINTIMELONGCOOKIE0 user's most recent logon time CLASTLOGINTIMELASTLOGINTIMELONGCOOKIE0 user's most recent logon time Clastlogintimelastlogintimelongcooki E0 user's most recent logon time generates good Java code: <% @page import= "Com.lizongbo.util.JSPUtil"%>//user's logon name string rloginusername = Jsputil. GetParameter (Request, "Loginusername", Lizongbo); User's logon name string Rloginusername = Jsputil. GetParameter (Request, "Loginusername", Lizongbo); User's logon name string rloginusername = Jsputil. GetParameter (Request, "Loginusername", Lizongbo); stored in the session password string suserpass = Jsputil.getattribute (Session, "Userpass", password); stored in the session password string suserpass = Jsputil.getattribute (Session, "Userpass", password); stored in the session password string suserpass = Jsputil.getattribute (Session, "Userpass", password); User's most recent logon time long clastlogintime = Jsputil. GetValue (Request.getcookies (), "Lastlogintime", 0); User's most recent logon time long clastlogintime = Jsputil. GetValue (Request.getcookies (), "Lastlogintime", 0); User's most recent logon time long clastlogintime = Jsputil. GetValue (Request.getcookies (), "Lastlogintime", 0); The Jsputil code snippet I encapsulated: public static string GetParameter (HttpServletRequest request, string name, string defval) { string param = request.getparameter (name); return (param!= null. param:defval); } public static Boolean getparameter (Httpser Vletrequest request, String name, boolean Defval) { String bv = Request.getparameter (name); return BV = null? Defval:parseboolean (BV); } public static double GetParameter (HttpServletRequest request, String name, Double defval) { return parsedouble (request.gEtparameter (name), defval); } public static float getparameter (HttpServletRequest request, string name, float Defval) { return parsefloat (Request.getparameter (name), defval); } public static int GetParameter (HttpServletRequest request, String name, int defval) { return parseint (Request.getparameter (name), defval); } public static long GetParameter (HttpServletRequest request, String name, & Nbsp; long Defval) { return Parselong (Request.getparameter (name), defval); } public static short GetParameter ( HttpServletRequest request, String name, short Defval) { return Parseshort (Request.getparameter (name), defval); }