發表文章

目前顯示的是 5月, 2015的文章

[javascript]object array sort example

  //陣列   var array = [ { ID:1, Name:'Chou' }, { ID:5, Name:'Lee' }, { ID:3, Name:'Chen' } ];   //依照ID排序   array.sort(function (a, b) {     return a.ID > b.ID ? 1 : -1;   }); //依照時間排序 var array2 = [ { ID:1, Date:'2015-01-01T23:59:59' },  { ID:5, Date:'2015-01-04T13:00:00' },  { ID:3, Date:'2015-01-05T14:00:00' } ];  Data.sort(function (a, b) { return new Date(b.Date) - new Date(a.Date); });

[API Server] JAX-RS 使用 Jersey 2.1.7 架設筆記

使用Jersey 建立Restful Server 架設環境如下 Java 6 Tomcat 7 (Tomcat 5 版會有問題,暫不處理) Maven Jersey 2.17 1. 設定pom.xml     <dependency>       <groupId>org.glassfish.jersey.containers</groupId>       <artifactId>jersey-container-servlet</artifactId>       <version>2.17</version>     </dependency>       <dependency>       <groupId>org.glassfish.jersey.containers</groupId>       <artifactId>jersey-container-servlet-core</artifactId>       <version>2.17</version>     </dependency> 2. 建立API Server所指定到的路徑 package com.example.jaxrs; import javax.ws.rs.ApplicationPath; import org.glassfish.jersey.server.ResourceConfig; @ApplicationPath("API") //所指定的網頁路徑 public class MyApplication extends ResourceConfig {   public MyApplication() {     packages("com.example.jaxrs"); //指定搜尋哪個packages   } } 3.建立CORSFilter  為什麼要建立這個呢主要是API SERVER 有可能跟所要存取