JAVA学习日记页面静态化方案

JAVA学习日记页面静态化方案(借鉴了:http://www.agilejava.org/space/?233的 生成静态页面技术解决方案系列,见我的转帖:一个实现将JSP动态页面转为静态的方案(转帖)

1、首页和帖子页面静态化,帖子列表不静态化;

2、列表上的帖子用静态化链接;

3、隐私帖子页面不静态化;用户登录后用动态化链接,所以可以看到隐私帖子;

4、静态化时机:

  1)、发公开帖子;

  发公开目标:静态化目标和首页;

  公开日记:静态化日记、目标和首页;

  公开评论:评论日记:静态化日记、目标、首页;评论目标:静态化目标、首页;

  发私人日记:不作任何静态化;

  2)、修改公开帖子;

  修改目标(目标不能修改隐私属性):

  修改公开目标:目标、首页;

  修改私有目标:不作任何静态化;

  修改日记(日记可以修改隐私属性):

  修改公开日记,并且修改后仍是公开帖子:静态化日记、目标、首页;

  修改公开日记,但是修改后的日记是私有帖子:删除已经静态化日记,重新静态化目标、首页;

  修改私有日记,并且修改后仍是私有帖子:不作任何静态化;

  修改私有日记,但是修改后成了公开日记:静态化日记、目标、首页; 

  修改评论(评论的隐私属性与被它评论的目标或日记一致)

  修改公开目标的评论:静态化目标、首页;

  修改公开日记的评论:静态化日记、目标、首页;

  修改私有目标的评论:不作任何静态化;

  修改私有日记的评论:不作任何静态化;

  3)、删除帖子(私有帖子是不能被删除的);

  删除公开目标:删除目标会删除此目标下的评论和日记和日记的评论,所以要:删除已静态化的目标、删除已静态化的目标的日记、重新静态化首页;

  删除公开日记:删除日记会删除此日记下的评论,所以要:删除已经静态化的日记、重新静态化首页;

  删除公开评论:删除目标的公开评论:重新静态化目标、首页;删除日记的公开评论:重新静态化日记、日记的目标、首页;

 

  4)、静态化种类:

  手动静态化:由管理员执行手动全面静态化及维护工作:包括:对数据库和静态化文件储存目标扫描,重新静态化应该静态化的帖子;如果某个不应该静态化的私有目标或日记被静态化了则删除已静态化的文件,并且作下记录,分析原因;

  定时静态化:同手动静态化一样的功能,只不过由系统定时进行,比如每晚12:00点;

  帖子变动时的静态化:如上面的列表;

5、其它注意事项:

  1)、为了统一静态化页面和简要设计和增加系统灵活性,现对登录用户和游客用户(包括搜索引擎)的静态化作一区别:

  登录用户:全部用动态化,也就是说与现在动态化的系统没有区别;从各论坛和网站的统计情况来看:登录用户占全部用户的比例一般在5%左右,所以不会系统有什么大的影响;

  未登录用户(包括搜索引擎):首页和帖子全部用静态化,游客提交评论后通过Action的301跳转进入已静态化的最新页面,但是提交评论的表单已经静态化了,所以不能记住用户,这可以放在以后解决,同屏蔽垃圾留言的设计一起进行,可能会用<frame>内嵌表单来做。

  2)、类的设计:

  1个执行实际静态化的类:ToHtml.java;1个模拟游客访问,调用静态化的工具类:CallHtml.java;再增加一个静态化文件管理类:HtmlsManager.java,用于封装各种静态化时机的操作,包括:

  1>,提交帖子:doPostArt(),传入提交的帖子作为参数,即为doPostArt(ArticleInfo postedArt);

  2>,修改帖子:doEditArt(),传入修改前的帖子和修改后的帖子作为参数,即为:doEditArt(ArticleInfo oldArt, ArticleInfo newArt);

  3>,删除帖子:doDelArt(),传入被删除的帖子作为参数,即为:doDelArt(ArticleInfo);

  4>,检测是否相应静态化文件的方法:isExist(String phyFullName),传入系统路径的包含路径的全文件名作为参数;

  5>,删除一个相应静态化文件的方法:delete(String phyFullName),传入系统路径的包含路径的全文件名作为参数;

解密.htm.html.shtm.shtml的区别与联系(转帖)

转自:(http://tech.sina.com.cn/s/2006-04-24/1654915865.shtml)

今天,在做JAVA学习日记的首页静态化过程中想到一个问题,静态文件的后缀名用.htm还是用.html呢?它们有什么区别吗?是不是像图像文件后缀名:.jpg和.jpeg一样呢?

下面是一篇转帖正文。

*************************************************************************

                                           

                          解密.htm.html.shtm.shtml的区别与联系

    ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

                 http://www.sina.com.cn 2006年04月24日 16:54 天极yesky

      作者:猴年马月

      每一个网页或者说是web页都有其固定的后缀名,不同的后缀名对应着不同的文件格式

    和不同的规则、协议、用法,最常见的web页的后缀名是.html和.htm,但这只是web页最基

    本的两种文件格式,今天我们来介绍一下web页的其它一些文件格式。

   

    [adfshow]

    [xfrd_01]                                          ●

      首先介绍一下html与htm

      关于HTML,HTML(HyperTextMark-upLanguage)即超文本标记语言,是WWW的描述语言。

    设计HTML语言的目的是为了能把存放在一台电脑中的文本或图形与另一台电脑中的文本或

    图形方便地联系在一起,形成有机的整体,人们不用考虑具体信息是在当前电脑上还是在

    网络的其它电脑上。我们只需使用鼠标在某一文档中点取一个图标,Internet就会马上转

    到与此图标相关的内容上去,而这些信息可能存放在网络的另一台电脑中。 HTML文本是由

    HTML命令组成的描述性文本,HTML命令可以说明文字、图形、动画、声音、表格、链接等

    。HTML的结构包括头部(Head)、主体(Body)两大部分,其中头部描述浏览器所需的信息,

    而主体则包含所要说明的具体内容。

      关于HTM,实际上HTM与HTML没有本质意义的区别,只是为了满足DOS仅能识别8+3的文

    件名而已,因为一些老的系统(win32)不能识别四位文件名,所以某些网页服务器要求

    index.html最后一个l不能省略。MSIE能自动识别和打开这些文件,但编写网页地址的时候

    必须是完全对应的,也就是说index.htm和index.html是两个不同的文件,对应着不同的地

    址。值得一提的是UNIX系统中对大小写敏感,不吻合的话就可能报没有文件或者找不到文

    件。

      其次介绍一下shtml和shtm

      关于shtml,shtml是一种基于SSI技术的文件,也就是Server Side Include--SSI 服

    务器端包含指令,一些Web Server如果有SSI功能的话就会对shtml文件特殊招待,服务器

    会先扫一次shtml文件看没有特殊的SSI指令存在,如果有的话就按Web Server设定规则解

    释SSI指令,解释完后跟一般html一起调去客户端。

      关于shtm,shtm与shtml的关系和htm与html的关系大致相似,这里就不多说了。

      html或htm与shtml或shtm的关系是什么

      html或者htm是一种静态的页面格式,也就是说不需要服务器解析其中的脚本,或者说

    里面没有服务器端执行的脚本,而shtml或者shtm由于它基于SSI技术,当有服务器端可执

    行脚本时被当作一种动态编程语言来看待,就如asp、jsp或者php一样。当shtml或者shtm

    中不包含服务器端可执行脚本时其作用和html或者htm是一样的。

********************************************************************************

                                      转帖完毕

JSP中读文件和写文件的例子(转帖)

转自:(http://www.programfan.com/article/showarticle.asp?id=2495


 <%@ page import="java.io.*" %>

<html>

  <head>

    <title>Lion互动网络==》JSP中读文件和写文件的例子</title>

  </head>

  <body>

   <%

//写文件

String str = "WWW.LIONSKY.NET";

String filename = request.getRealPath("lionsky.txt");

java.io.File f = new java.io.File(filename);

if(!f.exists())//如果文件不存,则建立

{

  f.createNewFile();

}

try

{

  PrintWriter pw = new PrintWriter(new FileOutputStream(filename));

  pw.println(str);//写内容

  pw.close();

}

catch(IOException e)

{

  out.println(e.getMessage());

}

//读文件

java.io.FileReader fr = new java.io.FileReader(f);

char[] buffer = new char[10];

int length; //读出的字符数(一个中文为一个字符)

//读文件内容

out.write(filename+"<br>");

while((length=fr.read(buffer))!=-1)

{

  //输出

  out.write(buffer,0,length);

}

fr.close();

%>

  </body>

</html>

本栏文章均来自于互联网,版权归原作者和各发布网站所有,本站收集这些文章仅供学习参考之用。任何人都不能将这些文章用于商业或者其他目的。( ProgramFan.Com )

在Struts Action对象中得到类似jsp页面application的ServletContext

今天需要把数据存在网站程序全局范围,需要在struts Aciton对象中得到 ServletContext对象,与jsp页面的application一样。在google中搜索到如下帖子。转帖于此:

How to get 'application' in Struts Action class? (转自:http://forum.java.sun.com/thread.jspa?threadID=609998&messageID=3346689

×××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××

How to get 'application' in Struts Action class?  

Mar 23, 2005 7:45 PM

Click to email this message

 

Hello,

I have a question on how to get 'application' in Struts Action class.

In the jsp file, i have set an application attribute:

<%

applicaiton.setAttribute("userId", "testUser");

%>

But how to get this application attribute in Struts Action class?

So far I only know how to get session in Struts Action class by using:

(HttpServletRequest)request.getSession();

 

[Dukes Earned 1425] evnafets

Posts:7,577

Registered: 29/04/03

Re: How to get 'application' in Struts Action class?  

Mar 23, 2005 8:08 PM (reply 1 of 2)

Click to email this message

 

The "application" in a JSP page is the ServletContext object.

In a standard servlet you can use

ServletContext application = getServletConfig().getServletContext();

In a Struts Action class, just have to get hold of the servlet first

ServletContext application = getServlet().getServletConfig().getServletContext();

Cheers,

evnafets

 

[Dukes Earned 0] nonameisname

Posts:24

Registered: 8/13/03

Re: How to get 'application' in Struts Action class?  

Mar 23, 2005 8:33 PM (reply 2 of 2)

Click to email this message

 

Hi evnafets,

Thanks a lot for your help. It works.

By the way, i found that it is possible to get ServletContext in Struts in two ways:

ServletContext application = getServlet().getServletConfig().getServletContext();

or

ServletContext application = getServlet().getServletContext();

Both work fine. Any concern about the 2nd way? It does not getServletConfig() but instead it straight away getServletContext().

*********************************************************************************************************

                       转帖完毕

一个实现将JSP动态页面转为静态的方案(转帖)

最近早上的时候发现首页很难完整打开(其它页正常),搞不懂为什么白天网络繁忙的时候才有可能出现问题在早上出现。我看了网络当前用户只有我一个人,但是数据库当前又只有两个连接(加上我查询连接数据的一个共3个)。不知道是不是这时是搜索引擎们勤奋工作的结果。但老是这样下去也不是办法。

解决的办法有两个:1、缓存数据;2、页面静态化;

暂时想只把首页的数据进行尽量简单的缓存,也许根本就不叫真正意义的缓存,把首页的数据存在程序全局变量中,只有帖子提交后才更新其中的数据。

这样,当首页要取数据时就不用读数据库了。如果这样还不行的话就试试先把首页静态化。再不行的话只有问问空间提供商了。

下面是转帖的一个JSP动态页面静态化的一个方案,贴在这里备用。

***********************************************************************************************************

一个实现将动态页面转为静态的方案(转自:http://java.ccidnet.com/art/3741/20061008/915263_1.html

 

正文

************************************************************************************************************

 

1.前言

为了能深入浅出的理解这个框架的由来,我们首先来了解一下JSP解析器将我们写的JSP代码转换成的JAVA文件的内容。

下面是一个JSP文件test.jsp

<%@ page language=java contentType=text/html;charset=GB2312 %>

<%

out.write();

%>

<%= 输出%>

经过TOMCAT转换出的JAVA文件test$jsp.java内容如下:

package org.apache.jsp;

import javax.servlet.*;

import javax.servlet.http.*;

import javax.servlet.jsp.*;

import org.apache.jasper.runtime.*;

 

public class test$jsp extends HttpJspBase {

 

    static {

    }

    public testOutRedir$jsp( ) {

    }

 

    private static boolean _jspx_inited = false;

 

    public final void _jspx_init() throws org.apache.jasper.runtime.JspException {

    }

 

    public void _jspService(HttpServletRequest request, HttpServletResponse  response)

        throws java.io.IOException, ServletException {

 

        JspFactory _jspxFactory = null;

        PageContext pageContext = null;

        HttpSession session = null;

        ServletContext application = null;

        ServletConfig config = null;

        JspWriter out = null;

        Object page = this;

        String  _value = null;

        try {

 

            if (_jspx_inited == false) {

                synchronized (this) {

                    if (_jspx_inited == false) {

                        _jspx_init();

                        _jspx_inited = true;

                    }

                }

            }

            _jspxFactory = JspFactory.getDefaultFactory();

            response.setContentType(text/html;charset=GB2312);

            pageContext = _jspxFactory.getPageContext(this, request, response,

                            , true, 8192, true);

 

            application = pageContext.getServletContext();

            config = pageContext.getServletConfig();

            session = pageContext.getSession();

            out = pageContext.getOut();

                //为了节省篇幅,我删除了解释器添加的注释

                out.write(\r\n);

//上一句是由于<%@ page language=java  contentType=text/html;charset=GB2312 %>后面的换行产生的

                out.write();

                out.write(\r\n\r\n\r\n\r\n);

                out.print( 输出 );

                out.write(\r\n\r\n\r\n\r\n);

        } catch (Throwable t) {

            if (out != null && out.getBufferSize() != 0)

                out.clearBuffer();

            if (pageContext != null) pageContext.handlePageException(t);

        } finally {

            if (_jspxFactory != null) _jspxFactory.releasePageContext(pageContext);

        }

    }

}

从上面的代码中可以清晰的看到JSP内建的几个对象(out、request、response、session、pageContext、application、config、page)是怎么产生的,懂servlet的朋友一看就能明白。

下面重点理解一下out对象,它被声明为JspWriter类型,JspWriter是一个抽象类,在包javax.servlet.jsp中可以找到它的定义。

abstract public class javax.servlet.jsp.JspWriter extends java.io.Writer{

       final public static int NO_BUFFER = 0;

       final public static int DEFAULT_BUFFER = -1;

       final public static int UNBOUNDED_BUFFER = -2;

       protected int bufferSize;

       protected Boolean autoFlush;

       protected javax.servlet.jsp.JspWriter(int arg1, boolean arg2);

     

    abstract public void newLine() throws IOException ;

    abstract public void print(boolean arg0) throws IOException ;

    abstract public void print(char arg0) throws IOException ;

    abstract public void print(int arg0) throws IOException ;

    abstract public void print(long arg0) throws IOException ;

    abstract public void print(float arg0) throws IOException ;

    abstract public void print(double arg0) throws IOException ;

    abstract public void print(char[] arg0) throws IOException ;

    abstract public void print(String arg0) throws IOException ;

    abstract public void print(Object arg0) throws IOException ;

    abstract public void println() throws IOException ;

    abstract public void println(boolean arg0) throws IOException ;

    abstract public void println(char arg0) throws IOException ;

    abstract public void println(int arg0) throws IOException ;

    abstract public void println(long arg0) throws IOException ;

    abstract public void println(float arg0) throws IOException ;

    abstract public void println(double arg0) throws IOException ;

    abstract public void println(char[] arg0) throws IOException ;

    abstract public void println(String arg0) throws IOException ;

    abtract public void println(Object arg0) throws IOException ;

    abstract public void clear() throws IOException ;

    abstract public void clearBuffer() throws IOException ;

    abstract public void flush() throws IOException ;

    abstract public void close() throws IOException ;

    public int getBufferSize() ;

    abstract public int getRemaining() ;

    public boolean isAutoFlush() ;

}

我相信当我写到这里你可能已经知道我想怎么做了。是的,来个偷天换日,继承JspWriter类,然后实现其定义的虚函数,然后把out变量替换成你自己实现的类的实例就ok了。

2.实现替换

假设

<%@ page language=java  contentType=text/html;charset=GB2312 import=jwb.util.HtmlIntoFile,jwb.util.TempSinglet,java.io.File%><%

JspWriter out_bak = out;String arg1=argument1;String filePath = /cache/根据参数生成文件名_ + arg1 + .html;//首先判断文件是否已经存在,如果不存在则执行本页面,否则跳转到静态页面就OK了File f = new File(pageContext.getServletContext().getRealPath(filePath));if(f.exists()) { out_bak.clear(); pageContext.forward(filePath); System.out.println(直接转到静态页面); return;}out = new HtmlIntoFile(pageContext.getServletContext().getRealPath(filePath));out.write();

%><%= 看吧,这就是输出被重定向到文件的实现,很简单吧^_^%><%out.close();//关闭生成的静态文件out_bak.clear();pageContext.forward(filePath);

System.out.println(执行本页面后再转到静态页面);return;%>

3.更新问题

下面就讨论一下如何更新生成静态文件,其实从上面实现中你可以看到,很简单的就是将生成的静态文件删除即可,至于什么时候删除,要看你的需求了。我能想到的几种情况如下

    *

      当用来生成页面的数据更新时

    *

      如果不需要很提供时时的数据可以定时更新

    *

      永远不更新

*********************************************************************************************************

                                                        转帖完毕

跳来跳去的adsense广告和在文章中广告文字绕排

  网站需要运行,google广告是一个途径,我认为不应绝对的排斥广告

  前一段时间我发现广告的点击率由1~1.5%下降为0.5~0.8%,就想是不是一成不变的广告对朋友已经失去吸引力,于是用代码让广告随机的变位置和种类。结果经过3天的试验效果,点击率更是下降到了0.1%。

  看来,还是固定位置的广告要好点呀。聊胜于无吧。

  现在的广告形式是页面头尾是大横幅,文章开头绕排一个200×200的正方形广告。

  另外,我申请了google广告的自定义渠道报告分析,从今天的效果来看,还是菜单顶部的效果好于中部和底部。

  可见,网页广告成功的要素还是醒目为主,那种像我那样不断变种类和位置的跳来跳去的广告是不行的。

附:一、jsp页面的元素随机跳动代码

 下面附上我的jsp页面的元素随机跳动代码,使用的是Struts+JSTL+JSP。很简单:

  1、随机数发生器:


package com.learndiary.website.util;

import java.util.Random;

import com.learndiary.website.Constants;

/**

 * generate random int between 0 (inclusive) and the specified value: Constants.MAX_RANDOM (exclusive),

 */

public class Randomer {

  private int i;

  public int getI() {

    return new Random().nextInt(Constants.MAX_RANDOM);

  }

}

  2、在用户进入页面后在session中保留一个 Randomer的对象。

  3、在页面和JSTL调用事先在google帐户中复制下来的代码:


 <c:set var="j" value="2"/>

 <c:set var="k" value="5"/>

 

 

 <c:if test="false">

  <div align="left">

 </c:if>

 <c:if test="false">

  <div align="center">

 </c:if>

 <c:if test="false">

  <div align="right">

 </c:if>

 

  <c:if test="false">

  <%@ include file="/guanggao/234.jsp" %>

  </c:if>

 

  <c:if test="false">

  <%@ include file="/guanggao/468.jsp" %>

  </c:if>

 

  <c:if test="false">

  <%@ include file="/guanggao/728.jsp" %>

  </c:if>

 

  <c:if test="false">

  <%@ include file="/guanggao/link_728.jsp" %>

  </c:if>

 

  <c:if test="false">

  <%@ include file="/guanggao/ref_firefox.jsp" %>

  </c:if>

 

  <c:if test="false">

  <%@ include file="/guanggao/ref_firefox_en.jsp" %>

  </c:if>

 

  <c:if test="false">

  <%@ include file="/guanggao/ref_pic.jsp" %>

  </c:if>

 

  <c:if test="false">

  <%@ include file="/guanggao/ref_pic_en.jsp" %>

  </c:if>

 

 </div>

  总觉得这样写可以让页面简洁一点,也许效率比直接写在jsp页面的要差一点?不知道。

 二、google adsense被文字绕排的效果 (相关代码来自google上的论坛,好像是:http://groups.google.com/group/adsense-help-zhs,具体位置忘了)

1、

 


     <table cellSpacing=0 cellPadding=10 align=left border=0>

      <tr>

       <td style="border-style: dotted; border-width: 0">

        <%@ include file="/guanggao/200_200.jsp" %>

       </td>

      </tr>

     </table>

     <p style="text-indent: 3">

     <bean:write name="aGoal" property="articleText" scope="request" filter="false"/><!--文章内容-->

 

但是我发现google广告在文章头部的加载时间太长严重影响了文章的显示,于是,根据原来学到的让del.icio.us不影响页面的加载(转帖),改进了代码如下:

内容部分:


     <font face="Ms Song"><font face="宋体">

     <table cellSpacing=0 cellPadding=10 align=left border=0>

      <tr>

       <td style="border-style: dotted; border-width: 0">

        <div id="daily_loading">loading...</div>

        <div id="daily_show" style="display:none;"></div>

       </td>

      </tr>

     </table>

     <p style="text-indent: 3">

     <bean:write name="aGoal" property="articleText" scope="request" filter="false"/><!--文章内容-->

     </font></font>

在</body>和</html>之间的部分:

<script type="text/javascript">

 

   function daily() {

 

       document.getElementById("daily_loading").style.display = 'none';

       document.getElementById("daily_loaded").style.display = 'none';

       document.getElementById("daily_show").innerHTML=document.getElementById("daily_loaded").innerHTML;

       document.getElementById("daily_show").style.display = 'block';    

   };

 

   window.onload = daily;

 

</script>

<div id="daily_loaded" style="display:none">

<%@ include file="/guanggao/200_200.jsp" %>

</div>

以上代码供对有同样需求的朋友参考,热切的希望您的任何意见和建议,谢谢。

大家好(转帖jjj的留言)

这是网友jjj的留言,因为本站留言不公开。故按jjj的本来意愿将其复制在此。

×××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××

 标题: 大家好  作者: jjj  创建时间: 2006-11-27 21:08:45

内容

好长时间没有来这里了,从04年学习日记开发开始到现在。快2年了。非常想念大家。

我在业余时间开发了一个网站。希望大家有空过去看看。

http://www.xiansky.com

是一个软件开发论坛。目前都是一些西安软件园的开发者,也欢迎大家过去讨论问题。

关于开源项目的看法(转自jjj留言)

注:这篇帖子是朋友jjj在2004年在本站的留言。因本站留言不公开,所以按jjj的本来意思把这篇帖子复制在此。

××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××

 标题: 关于开源项目的看法(转自jjj留言)  作者: littlebat  创建时间: 2004-12-24 15:16:38  最近更新: 2005-10-25 01:19:28  编辑   删除

内容

学习日记小组的各位大家好:

我使一个新加入的新手,请多关照,以下是我的一些拙见,望别见笑,不妥之处请指正!谢谢~

       

Java之所以可以在今天如火如荼,不是因为它是最优秀的语言!说实话,我喜欢c++更甚于java(大学和刚毕业时我一直用vc)。但是有一点必须重视,java有许多开源的东西。众所周知,java的IDE:Eclipse!

并且java的开放并不仅仅局限这些东东。他有好多开放的源码让我们参考并且可以说是拷贝,世界上的众多高手们都在为java做努力,创造了很多好的工具和包。

         就具体的项目开发来说,我们离不开这些工具和包(那Eclipse举例吧)

1.     

IDE开发环境:网上直接下载!这个集成开发环境自我感觉很不错,除了耗点内存,其他的优点的却很多。

2.       版本控制:CVS插件,把它嵌入到Eclipse中很方便,只需要

CheckOut,Update,Commit,Rep.........etc一切都很方便。为团队开发创造了很多方便,纵然我们都相隔千里之外。

3.       打包:Maven插件,

有了它,Eclipse发挥的作用就更明显了。以前很多包都要手工生成,但只要给Eclipse里装了这个插件。我们的工作就减轻了很多,只需要对相应文件打包,就可以轻松的发布了!

具体打法如下:Action和Form文件: jar:install-snapshot

                            jsp  page文件和struts-config文件:

war:install-snapshot

                            ejb文件:ejb:install-snapshot

                            开发库: (我的是develop)  : ear

                            实体(Entity)  :jar:install-snapshot

                            Configfiles:  jar:install-snapshot

   

比如说你修改了你的Ejb,给里面加了几个方法,想在Action中调用,只需要对Action的project.xml执行Eclipse就可以导入相应的包。

4.        日志管理:    log4j      

开发中的输出日志是很重要的,如果在项目中大量的使用System.println();输出错误信息,无疑对一个项目是有害的。调试的时候觉得还可以,可到了后期就成了一种负担,所以使用Log4j,它的使用方法很简单,并且对异常的捕获处理的很好,几种不同优先级输出方式。对各种 Exception处理的很好。log.info();log.debug();log.error();

等等。。

5。       Hibernate

,别说Ejb有多么优秀,但是hibernate有许多Ejb无法处理的。比如说事务吧,当出现无法预料的环境时,事务的回滚操作。在平时看起来不是很严重,但如果牵扯一笔很大的交易,损失不言而喻,并且他

的Po操作很方便! 也很安全!其中的Hql语句到现在我还很佩服!  在写jsp

页面时很好用!不用每次都用什么formbean 的,直接name="po"  "PO as po"

页面直接写就可以了!!  

继承一个公用的QueryAction,不同页面写不同的实体即可!

6.         运行环境: 就不说了,我开发时用的是Weblogic

8.1,软件发布以后在WebSphere上跑!

好了,就说这么多吧,该回家陪我们家咪咪了!88,住学习日记的所有人好运,圣诞快乐!

注册用户公告信息发布区

因为看到有朋友在本站发布留言想公告自己的一些技术信息和网站信息,但是本站的留言是不公开的。所以,就无法满足朋友的愿望。

所以我们特别设置一个“注册用户公告信息发布区”供朋友发布技术相关的、合法和文明的公告(和广告)信息。

你必须以注册用户身份登录,在这个目标下提交的日记即为您的公告。

恳请在这里发布公告的朋友也能帮助宣传一下本站。请记住我们的网址:http://java.learndiary.com/,JAVA学习日记,分享目标,分享快乐。感谢您的来访和留言。

谢谢。

Thinking in Patterns Chapter 11: Flexible structure

Thinking in Patterns with Java V0.9: Chapter 11: Flexible structure: TIPatterns.htm#_Toc41169735

1, Sections:

  Composite

2, The main content and feeling:

  At first, the meaning of "Composite" has confused me a little. There is a

"Composition" and "Aggregation" terms in UML. And, I thought "Composite" in

GoF's design patterns as the "Composition" in UML. At last, I have known these

two terms are all totally different.

Here, I don't give the explaination of "Composition" term in UML, you can get

it at our site:

http://java.learndiary.com/disDiaryContentAction.do?goalID=1345

I understood the meaning of "Compostion" after reading the example://:

composite:CompositeStructure.java. The key is: The node and its child node has

the same operations, "and that performing an operation on a node/composite

also performs that operation on any children of that node/composite."

Just like an orgernization, there are some partions under this orgernization,

and alse maybe there are lower partions under the orgernization's partion.

When the leader of orgernization say: do(it), the entire orgernization start a

mission just "do(it)". Then, every partions of

orgernization and the lower partions of the orgernization's partion will also

perform this "do(it)" mission. But, the detail of "do(it)" in all these level

isn't same.

And, there is a point about "passing parameter to a java method" need be

noted.

See the code part below:


    Node c2 = new Node("Node1"); //Step 1

    //some code omited

    root.add(c2); //Step 2

    c2 = new Node("Node2"); //Step 3

    //some code omited

 

   root.add(c2); //Step 4

At Step 2, a duplicated copy of the address of object created at Step 1 passed

into method add(); and, the reference "c2" point to a new object, again,

another object's address be duplicated into the method add() at Step 4. Note,

the object pointed by "c2" at Step 2 will can't be changed by a new object to be

pointed by "c2".  

If you are confused with the "passing parameter into a java method" like

above, maybe, an article of mine titled with "Understanding Assignment and

Passing Parameters in Java with Term 'Stack Date Copy'" posted at:

http://java.learndiary.com/disDiaryContentAction.do?goalID=2716 can help you to understand it.

3, Questions about programming:

4, Questions about english language:

1), Strange words:

part-whole, containment, visitation,

2), Difficult sentences:

1>, The important thing here is that all elements in the part-whole have

operations, and that performing an operation on a node/composite also performs

that operation on any children of that node/composite.

                                     incomplete