Dec 22
以前一直使用Tomcat运行及调试,但最烦DW改完后还要在Eclipse刷一下,有时死刷新还不同步。
平时不喜欢MyEclipse,还是纯静的Eclipse用起来快。
Eclipse+Jetty用起来果然比较爽。。。

Jetty7 lib包:jetty7_lib

1、把Jetty的包加入项目,把tomcat相关包去掉.
2、在Eclipse的Debug Configurations -> Java Appliction 右键New
    
     Main class:中输入 org.mortbay.xml.XmlConfiguration
     Arguments 选项中的Program arguments:${workspace_loc:工程名称}/jetty.xml,jetty.xml 放在工程根目录下

    VM 可以配为: -Xms128m -Xmx512m -XX:PermSize=128M -XX:MaxPermSize=256m

3、jetty.xml配置:



    
Tags: ,
Dec 8
前阵子不知道怎么搞的,Eclipse项目工程VSS签出状态不见了,也不知道从哪里设置,Eclipse还是会提示,签入也是成功,就是不见状态,比较麻烦,自己找了好久没有找不到在哪里设,GOOGLE一下,找到设置的地方。

Window -> Preferences  -> General  -> Appearance -> Label Decorations

找到 VSS Plugin Team  Decorator 项,勾上,签出状态出来了!
Nov 18




Nov 17
             
            

一、
             写jsp页面的时候,在struts2中,用的是s标记,先引入标记:
             <%@ taglib prefix="s" uri="/struts-tags"%>
             二、
             struts2的标签和1是完全不同的。
             struts2的标签分为两大类:非UI标志和UI标志 struts1 将标志库按功能分成HTML、Tiles、Logicå’ŒBean等几部分
             下面就介绍strut2的具体标签:
             1、UI
UI标志又可以分为表单UI和非表单UI两部分。表单UI部分基本与Struts 1.x相同,都是对HTML表单元素的包装。不过,Struts 2.0加了几个我们经常在项目中用到的控件如:datepicker、doubleselect、timepicker、 optiontransferselect等。因为这些标志很多都经常用到,而且参数也很多,要在一篇文章详细说明并非易事。
             下面主要是ui标签的一些用法
             form:
             <s:form action="exampleSubmit" method="post" enctype="multipart/form-data">
             <s:submit />
                  <s:reset />

            

</s:form>可以上传文件的form。
             textfield:
             <s:textfield
                          label="姓名:"
                          name="name"
                          tooltip="Enter your Name here" />
             datepicker:
             <s:datepicker
                          tooltip="Select Your Birthday"
                          label="生日"
                          name="birthday" />
             textarea:
             <s:textarea
                          tooltip="Enter your remart"
                          label="备注"
                          name="remart"
                          cols="20"
                          rows="3"/>
             select:
             <s:select
                          tooltip="Choose user_type"
                          label=""
                          list="#{'free':'免费','vip':'收费'}" value="#{'free':'免费'}"    
                         name="bean.user_type"
                          emptyOption="true"
                          headerKey="None"
                          headerValue="None"/>
             <s:select
                          tooltip="Choose user_type"
                          label=""
                          list="#{'free':'免费','vip':'收费'}" value="#{'free':'免费'}"    
                         name="bean.user_type"
                          emptyOption="true"
                          headerKey="None"
                          headerValue="None"/>
             <s:select
             list="venderList"
             listKey="id"
             listValue="name"
             value="%{profile.companyName}"
             name="companyName" cssClass="sel_style_w_180"/>    
             挺好用的
             checkboxlist:
             <s:checkboxlist
                          tooltip="Choose your Friends"
                          label="朋友"
                          list="{'Patrick', 'Jason', 'Jay', 'Toby', 'Rene'}"
                          name="friends"/>
             checkbox:
                 <s:checkbox
                          tooltip="Confirmed that your are Over 18"
                          label="年龄"
                          name="legalAge"
                          value="18"/>
             file:
                 <s:file
                          tooltip="Upload Your Picture"
                          label="Picture"
                          name="picture" />
             a:
             <s:a xhref="getP.jsp">超链接提交</s:a>
             date :
             <s:date name="ad_end_time" format="yyyy-MM-dd"/>

            


             2、非UI
             if、elseifå’Œelse 描述:
             执行基本的条件流转。
             参数:
             名称必需默认类型描述备注test是Boolean决定标志里内容是否显示的表达式else标志没有这个参数id否Object/String用来标识元素的id。在UI和表单中为HTMLçš„id属性 例子:
             <%@ page c %>
             <%@ taglib prefix="s" uri="/struts-tags" %>
             <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
             <html>
                  <head>
                      <title>Condition Flow</title>
                  </head>
                  <body>
                      <h3>Condition Flow</h3>              
                      <!--
                          è¿™é‡Œæœ‰ç‚¹å°æŠ€å·§ï¼š
                          æœ¬æ¥å¯ä»¥ç”¨#parameters.name[0]来获得,请求中name的值。但是,在我实现include例子时,
                          æ— è®ºæˆ‘用param标志给name赋任何值,#parameters里面不会含有任何值,所以#parameters.name也为空值。
                           
                          å…¶åŽŸå› ä¸ºï¼š
                          å½“使用include标志时,被包含的页面(included)里#parameters拿到的是包含页面里的请求参数。
                           
                          å› æ­¤ï¼Œè¿™é‡Œå¿…须手工调用request.getParameter("name")。
                      -->
                  <s:iterator value="linkList" status="bean">
                 <tr>
                  <td class="data_tab_tdcl">
                   <s:property value="#bean.Index+1" />     </td>
                  <td class="data_tab_tdcl"><s:property value="link_title" /></td>
                  <td class="data_tab_tdcl"><s:property value="link_url" /></td>
                  <td class="data_tab_tdcl">
                  <s:if test="link_type == 1">
                                 æ–‡å­—
                              </s:if>
                              <s:elseif test="link_type == 2">
                                 å›¾ç‰‡
                              </s:elseif>
                               <s:else>
                               -----
                             </s:else>     
                  </td>

            

     
                  </body>
             </html>
             例1 condition.jsp
             iterator 描述:
             用于遍历集合(java.util.Collection)或枚举值(java.util.Iterator)。
             参数:
名称必需默认类型描述status否String如果设置此参数,一个IteratorStatus的实例将会压入每个遍历的堆栈value否 Object/String要遍历的可枚举的(iteratable)数据源,或者将放入新列表(List)的对象id否Object/String用来 标识元素的id。在UI和表单中为HTML的id属性 例子:
             <%@ page c %>
             <%@ page import="java.util.List" %>
             <%@ page import="java.util.ArrayList" %>
             <%@ taglib prefix="s" uri="/struts-tags" %>

            

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
             <%
                  List list = new ArrayList();
                  list.add("Max");
                  list.add("Scott");
                  list.add("Jeffry");
                  list.add("Joe");
                  list.add("Kelvin");
                  request.setAttribute("names", list);
             %>
             <html>
                  <head>
                      <title>Iterator</title>
                  </head>
                  <body>
                      <h3>Names: </h3>
                      <!--
                          1、此处的空property元素用于获得当前iterator的值
            2、status被设成stuts,在iterator的里面就可以通过#stuts取得IteratorStatus的对象。 IteratorStatus类包含当前序号信息,如是否第一个或最后一个,是否为奇数序号。这些信息在我们做格式化的时候,显得非常有用。
                      -->
                      <ol>
                          <s:iterator value="#request.names" status="stuts">                  
                              <s:if test="#stuts.odd == true">
                                  <li>White <s:property /></li>
                              </s:if>
                              <s:else>
                                  <li style="background-color:gray"><s:property /></li>
                              </s:else>
                          </s:iterator>
                      </ol>
                  </body>
             </html>

            
            
  
1. Struts2页面开发中常用标签使用说明
1.1.往action里传值的使用方式:
<input name="userName" type="text" class="input6" size="15">
a. userName属性需要在访问的action中提供相应的属性,并有SET/GET方法。
b. 可以不在访问的action中提供相应的属性,用request.getParameter(“userName”);1.2.显示标签 property 用于输出指定值:
<s:property value=" userName "/> 当action返回到指定页面是,可以通过该标签显示action中的属性信息。(注 userName必须在action中存在,并有GET方法)。

1.3.往对象中传值<s:textfield> 用于从页面往action中的对象内传值:
<s:text[color=blue][/color]field name="user. userName " id="username"/>
该标签可以在页面中向action中的实体对象内直接传值。(注:在action中要存在user对象,并有SET/GET方法。)

1.4.判断<s:if> </s:if> 用于在页面中判断指定数据
<s:if test="userName == admin">…. </s:if>
<s:else>…. </s:else>
该标签用于对指定的数据进行判断,但指定的数据必须在action中存在。

1.5.迭代<s:iterator>用于将List、Map、ArrayList等集合进行循环遍历
<s:iterator value="userList" id="user" status="u">
<s:property value="userName"/></a>
</s:iterator>
该标签用于将userList集合中的元素进行循环,用过property进行显示集合中的指定元素值。

1.6.URL地址标签,<s:url>用于生成一个URL地址,可以通过URL标签指定的<s:param>子元素向URL地址发送请求参数
<s:url action=" ">
<s:param name=" " value=""></s:param>
</s:url>
其中action为请求地址,param子元素为地址后面所带的参数。

1.7.超链接 <a href >一般和<s:url>标签一起使用,用于带多个参数。
<a xhref="
<s:url action=" ">
<s:param name=" " value=""></s:param>
<s:param name=" " value=""></s:param>
<s:param name=" " value=""></s:param>
</s:url>">
超链接</a>

1.8.set标签,用于将某个值放入指定的范围内。例如application,session等。
<s:set name="user" value="userName" scope=”request”/>
将user值放入request范围内。

2. Struts2页面开发中常用标签使用规范:
1.1.通过<input name="userName" type="text" class=" " size="15">
往action中传值,action中要有相应的属性,并提供SET/GET方法。
(在数量少时可以使用request.getParameter(“userName”);)

1.2.在页面显示action传来的数据,使用property标签。需要显示的数据从action中获得。

1.3.往action中的实体对象内传值,使用textfield标签。

1.4.在页面中判断指定值使用<s:if>标签。判断数据从action中获得。

1.5.在页面中需要循环列表显示的数据使用<s:iterator>标签,列表数据从action中获得。

1.6.URL地址和超链接可以使用<a href>和<s:url>,在传多值时建议<a href>和<s:url>一起使用
Nov 17
作者: onebodysoftware@hotmail.com (MSN)
E文地址:http://wiki.opensymphony.com/display/CACHE/Configuration
这个东西今天小试了一下,总体感觉还不错.就不知道比起JBoss cache 有没什么差别(现在本人还不得而知啊)
主要是针对 osCache 的配置文件做了简单的翻译; 如有错误敬请修正.修改的文档请共享一下,谢谢!
oscache.properties  osCache的配置文件   放在 webapp/WEB-INF/classes/下;
oscache.properties 中的配置项如下:

1、cache.memory:
   原文:

      Valid values are true or false, with true being the default value. If you want to disable memory caching,
      just comment out or remove this line.
      Note: disabling memory AND disk caching is possible but fairly stupid

   译文:

      æ˜¯å¦ä½¿ç”¨å†…存缓存; true 或 false。默认为true;    
      ä¸ªäººæŽ¨èå†…存方法,在速度会有些优势;

2、cache.capacity

   原文:
       The maximum number of items that a cache will hold. By default the capacity is unlimited - the cache will never remove any items.
       Negative values will also be treated as meaning unlimited capacity.

   译文:
      ç¼“存的最大数量。默认是不限制,cache不会移走任何缓存内容。负数被视不限制。

3、cache.algorithm
   原文:
       The default cache algorithm to use. Note that in order to use an algorithm the cache size must also be specified.
       If the cache size is not specified, the cache algorithm will be Unlimited cache regardless of the value of this property. If you specify a size but not an algorithm, the cache algorithm used will be com.opensymphony.oscache.base.algorithm.LRUCache.

       OSCache currently comes with three algorithms:

             * com.opensymphony.oscache.base.algorithm.LRUCache - Least Recently Used.

              This is the default when a cache.capacity is set.

             * com.opensymphony.oscache.base.algorithm.FIFOCache - First In First Out.

             * com.opensymphony.oscache.base.algorithm.UnlimitedCache - Content that is added to the cache will never be discarded.

              This is the default when no value is set for the cache.capacity property.      

   译文:

       运算规则。为了使用规则,cacheçš„size必须是指定的。

       如果cacheçš„size不指定的话, 将不会限制缓存对象的大小。如果指定了cacheçš„size,但不指定algorithm,

       那它会默认使用:com.opensymphony.oscache.base.algorithm.LRUCache

       有下面三种规则:

           * com.opensymphony.oscache.base.algorithm.LRUCache       : last in first out(最后插入的最先调用)。默认选项。

           * com.opensymphony.oscache.base.algorithm.FIFOCache      : first int first out(最先插入的最先调用)。

           * com.opensymphony.oscache.base.algorithm.UnlimitedCache : cache中的内容将永远不会被丢弃。

           如果cache.capacity不指定值的话,它将被设为默认选项。



4、cache.blocking

   原文:

       When a request is made for a stale cache entry, it is possible that another thread is already in the process of rebuilding that

       entry. This setting specifies how OSCache handles the subsequent 'non-building' threads. The default behaviour

       (cache.blocking=false) is to serve the old content to subsequent threads until the cache entry has been updated.

       This provides the best performance (at the cost of serving slightly stale data). When blocking is enabled,

       threads will instead block until the new cache entry is ready to be served. Once the new entry is put in the

       cache the blocked threads will be restarted and given the new entry.

       Note that even if blocking is disabled, when there is no stale data available to be served threads will block until the data is

       added to the cache by the thread that is responsible for building the data.



   译文:

      æ˜¯å¦åŒæ­¥ã€‚true 或者 false。一般设为true,避免读取脏数据。



5。cache.unlimited.disk

   原文:

       Indicates whether the disk cache should be treated as unlimited or not. The default value is false.

       In this case, the disk cache capacity will be equal to the memory cache capacity set by cache.capacity.



   译文:

        æŒ‡å®šç¡¬ç›˜ç¼“存是否要作限制。默认值为false。false的状况下,disk cache capacity å’Œcache.capacity的值相同。



6、cache.persistence.class

   原文:

       Specifies the class to use for persisting cache entries. This class must implement the PersistenceListener interface.

       OSCache comes with an implementation that provides filesystem based persistence.

       Set this property to com.opensymphony.oscache.plugins.diskpersistence.HashDiskPersistenceListener to enable this implementation.

       By specifying your own class here you should be able to persist cache data using say JDBC or LDAP.

      

       NOTE: This class hashes the toString() of the object being cached to produce the file name of the entry.

             If you prefer readable file names, the parent DiskPersistenceListener can still be used but it will have issues with illegal

              filesystem characters or long names.



              The HashDiskPersistenceListener and DiskPersistenceListener classes require cache.

             path to be set in order to know where to persist the files to disk.

   译文:

       指定类是被持久化缓存的类。class必须实现PersistenceListener接口。

        ä½œä¸ºç¡¬ç›˜æŒä¹…,可以实现com.opensymphony.oscache.plugins.diskpersistence.HashDiskPersistenceListener接口。

        å®ƒæŠŠclassçš„toString()输出的hash值作为文件的名称。如果你要想文件名易读些(自己设定),DiskPersistenceListener 的父类也

         能使用,但其可能有非法字符或者过长的名字。

        

        æ³¨æ„ï¼šHashDiskPersistenceListener å’Œ DiskPersistenceListener 需要设定硬盘路径:cache.path



7、cache.path

   原文:

       This specifies the directory on disk where the caches will be stored. The directory will be created if it doesn't already exist,

       but remember that OSCache must have permission to write to this location. Avoid sharing the same cache path between different

       caches, because OSCache has not been designed to handle this.



       Note:

            For Windows machines, the backslash character '\' needs to be escaped. ie in Windows:

        

       cache.path=c:\\myapp\\cache

       or *ix:

       cache.path=/opt/myapp/cache



   译文:

       指定硬盘缓存的路径。目录如果不存在将被建立。同时注意oscache应该要有权限写文件系统。



       例:

         cache.path=c:\\myapp\\cache

         or *ix:

         cache.path=/opt/myapp/cache



8、cache.persistence.overflow.only (NEW! Since 2.1)

   原文:

       Indicates whether the persistence should only happen once the memory cache capacity has been reached.

       The default value is false for backwards compatibility but the recommended value is true when the memory cache is enabled.

       This property drastically changes the behavior of the cache in that the persisted cache will now be different then what is

       in memory.



   译文:

       指定是否只有在内存不足的情况下才使用硬盘缓存。

       默认值false。但推荐是true如果内存cache被允许的话。这个属性彻底的改变了cache的行为,使得persisted cacheå’Œmemory是完全不同。



9、cache.event.listeners

    åŽŸæ–‡:

       This takes a comma-delimited list of fully-qualified class names. Each class in the list must implement one (or more) of

       the following interfaces:



           * CacheEntryEventListener - Receives cache add/update/flush and remove events.

           * CacheMapAccessEventListener - Receives cache access events. This allows you to keep statistical information to track

             how effectively the cache is working.



       No listeners are configured by default, however some ship with OSCache that you may wish to enable:



           * com.opensymphony.oscache.plugins.clustersupport.BroadcastingCacheEventListener - provides clustering support for OSCache.

             Enabling this will cause cache flush events to be broadcast to other instances of OSCache running on your LAN.

             See Clustering OSCache for further information about this event listener.

           * com.opensymphony.oscache.extra.CacheEntryEventListenerImpl - a simple listener implementation that maintains a running

             count of all of the entry events that occur during a cache's lifetime.

           * com.opensymphony.oscache.extra.CacheMapAccessEventListenerImpl - a simple listener implementation that keeps count of

             all the cache map events (cache hits and misses, and stale hits) that occur on a cache instance.



    è¯‘æ–‡:

       class名列表(用逗号隔开)。每个class必须实现以下接口中的一个 或者几个

       CacheEntryEventListener:接收cache add/update/flush and remove事件

       CacheMapAccessEventListener :接收cache访问事件。这个可以让你跟踪cache怎么工作。

      

       默认是不配置任何class的。当然你可以使用一下的class:

           * com.opensymphony.oscache.plugins.clustersupport.BroadcastingCacheEventListener : 分布式的监听器。可以广播到局域网内的其他cache实例。

            * com.opensymphony.oscache.extra.CacheEntryEventListenerImpl :一个简单的监听器。在cache的生命周期中记录所有entry的事件。

            * com.opensymphony.oscache.extra.CacheMapAccessEventListenerImpl : 记录count of cache map events(cache hits,misses and state hits).

10、cache.key

    åŽŸæ–‡:

       This is the key that will be used by the ServletCacheAdministrator

       (and hence the custom tags) to store the cache object in the application and session scope.

       The default value when this property is not specified is "__oscache_cache". If you want to access this default value in your code,

       it is available as com.opensymphony.oscache.base.Const.DEFAULT_CACHE_KEY.



    è¯‘æ–‡:

        åœ¨application å’Œ session的作用域时 用于标识cache 对象的,  ç”¨äºŽServletCacheAdministrator;

        æ­¤å±žæ€§ä¸æ˜¯æŒ‡å®šä¸º"__oscache_cache"格式时为默认值, 如果代码中需要用到默认值时可以通使用com.opensymphony.oscache.base.Const.DEFAULT_CACHE_KEY

       来取得;



11、cache.use.host.domain.in.key

    åŽŸæ–‡:

        If your server is configured with multiple hosts, you may wish to add host name information to automatically generated

       cache keys. If so, set this property to true. The default value is false.



    è¯‘æ–‡:

        å½“配置多个服务器时,想通过服备器名称自动生成cache keyæ—¶,可将此属性设为true. 默认值为false;

      

12、Additional Properties

    åŽŸæ–‡:

        In additon to the above basic options, any other properties that are specified in this file will still be loaded and can be

       made available to your event handlers. For example, the JavaGroupsBroadcastingListener supports the following additional

       properties:



    è¯‘æ–‡:

        åœ¨ä»¥ä¸ŠåŸºç¡€é€‰é¡¹ä¹‹ä¸Šå¯ä»¥åŠ å…¥ä¸€äº›é¢å¤–的属性到此文件中.

       例:  JavaGroupsBroadcastingListener 便是额外的.



13、cache.cluster.multicast.ip

    åŽŸæ–‡:

        The multicast IP to use for this cache cluster. Defaults to 231.12.21.132.



    è¯‘æ–‡:

        ç”¨äºŽç¼“存集群. 默认为231.12.21.132



14、cache.cluster.properties

    åŽŸæ–‡:

        Specifies additional configuration options for the clustering. The default setting is

       UDP(mcast_addr=231.12.21.132;mcast_port=45566;ip_ttl=32;\

       mcast_send_buf_size=150000;mcast_recv_buf_size=80000):\

       PING(timeout=2000;num_initial_members=3):\

       MERGE2(min_interval=5000;max_interval=10000):\

       FD_SOCK:VERIFY_SUSPECT(timeout=1500):\

       pbcast.NAKACK(gc_lag=50;retransmit_timeout=300,600,1200,2400,4800;max_xmit_size=8192):\

       UNICAST(timeout=300,600,1200,2400):\

       pbcast.STABLE(desired_avg_gossip=20000):\

       FRAG(frag_size=8096;down_thread=false;up_thread=false):\

       pbcast.GMS(join_timeout=5000;join_retry_timeout=2000;shun=false;print_local_addr=true)

  

    è¯‘æ–‡:

        æŒ‡é›†ç¾¤ä¸­çš„额外配置项. 以下是默认设置:(此属性的相关说将在集群文档中说明)

       UDP(mcast_addr=231.12.21.132;mcast_port=45566;ip_ttl=32;\

       mcast_send_buf_size=150000;mcast_recv_buf_size=80000):\

       PING(timeout=2000;num_initial_members=3):\

       MERGE2(min_interval=5000;max_interval=10000):\

       FD_SOCK:VERIFY_SUSPECT(timeout=1500):\

       pbcast.NAKACK(gc_lag=50;retransmit_timeout=300,600,1200,2400,4800;max_xmit_size=8192):\

       UNICAST(timeout=300,600,1200,2400):\

       pbcast.STABLE(desired_avg_gossip=20000):\

       FRAG(frag_size=8096;down_thread=false;up_thread=false):\

       pbcast.GMS(join_timeout=5000;join_retry_timeout=2000;shun=false;print_local_addr=true)



原文:

    See the Clustering OSCache documentation for further details on the above two properties.



译文:

   以上两项的详细信息可以看 OSCache集群文档(http://wiki.opensymphony.com/display/CACHE/Clustering);



OSCache 的分布式缓存效果不佳, 所以最终决定不再继续研究下去.  åŒæ—¶è½¬å‘ehCache 的研究(文档正在整理当中)
Pages: 8/15 First page Previous page 3 4 5 6 7 8 9 10 11 12 Next page Final page [ View by Articles | List ]