·您的位置: 首页 » 资源教程 » 编程开发 » JAVA、JSP » 利用xml+xsl快速生成大量JSP的常用代码的方法.

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

类别: JAVA教程  评论数:0 总得分:0
利用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);  }


-= 资 源 教 程 =-
文 章 搜 索
关键词:
类型:
范围:
纯粹空间 softpure.com
Copyright © 2006-2008 暖阳制作 版权所有
QQ: 15242663 (拒绝闲聊)  Email: faisun@sina.com
 纯粹空间 - 韩国酷站|酷站欣赏|教程大全|资源下载|免费博客|美女壁纸|设计素材|技术论坛   Valid XHTML 1.0 Transitional
百度搜索 谷歌搜索 Alexa搜索 | 粤ICP备19116064号-1