利用xml+xsl快速產生大量JSP的常用代碼的方法.

來源:互聯網
上載者:User
js|xml 利用xml+xsl快速產生大量JSP的常用代碼的方法. 參考Jbuilder的Servlet嚮導來使用xml+xsl產生JSP的常用代碼。xml樣本: <?xml version="1.0" encoding="GB2312"?><?xml-stylesheet type="text/xsl" href="jspram.xsl"?><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>使用者的登入名稱</desc> </param> <param>  <variable>clastlogintime</variable>  <name>lastlogintime</name>  <type>long</type>  <src>cookie</src>  <default>0</default>  <desc>使用者最近一次的登入時間</desc> </param> <param>  <variable>suserpass</variable>  <name>userpass</name>  <type>String</type>  <src>session</src>  <default>password</default>  <desc>存放在session裡的密碼</desc> </param></jsp> xsl檔案略。  轉換後的效果圖和相關代碼: testjsp.jsp變數名字參數名字變數類型變數來源預設值備忘rloginusernameloginusernameStringrequestlizongbo使用者的登入名稱rloginusernameloginusernameStringrequestlizongbo使用者的登入名稱rloginusernameloginusernameStringrequestlizongbo使用者的登入名稱suserpassuserpassStringsessionpassword存放在session裡的密碼suserpassuserpassStringsessionpassword存放在session裡的密碼suserpassuserpassStringsessionpassword存放在session裡的密碼clastlogintimelastlogintimelongcookie0使用者最近一次的登入時間clastlogintimelastlogintimelongcookie0使用者最近一次的登入時間clastlogintimelastlogintimelongcookie0使用者最近一次的登入時間產生好的java代碼: <%@page import="com.lizongbo.util.JSPUtil"%>//使用者的登入名稱String rloginusername = JSPUtil. getParameter(request,"loginusername",lizongbo); //使用者的登入名稱String rloginusername = JSPUtil. getParameter(request,"loginusername",lizongbo); //使用者的登入名稱String rloginusername = JSPUtil. getParameter(request,"loginusername",lizongbo); //存放在session裡的密碼String suserpass = JSPUtil.getAttribute(session,"userpass",password); //存放在session裡的密碼String suserpass = JSPUtil.getAttribute(session,"userpass",password); //存放在session裡的密碼String suserpass = JSPUtil.getAttribute(session,"userpass",password); //使用者最近一次的登入時間long clastlogintime = JSPUtil. getValue(request.getCookies(),"lastlogintime",0); //使用者最近一次的登入時間long clastlogintime = JSPUtil. getValue(request.getCookies(),"lastlogintime",0); //使用者最近一次的登入時間long clastlogintime = JSPUtil. getValue(request.getCookies(),"lastlogintime",0);    我封裝的JSPUtil代碼片斷:   public static string getparameter(httpservletrequest request, string name,                                    string defval) {    string param = request.getparameter(name);    return (param != null ? param : defval);  }   public static boolean getparameter(httpservletrequest 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,                                  long defval) {    return parselong(request.getparameter(name), defval);  }   public static short getparameter(httpservletrequest request, string name,                                   short defval) {    return parseshort(request.getparameter(name), defval);  }

相關文章

Beyond APAC's No.1 Cloud

19.6% IaaS Market Share in Asia Pacific - Gartner IT Service report, 2018

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。