發表文章

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

Angularjs Dynamic From Action

In Controller   document. Form .action = 'http://www.example.com/API/Purchase'; In Html <form name=" Form ">  ... </form> then it should work

[jersey]Download file from Remote Server

從其他網站伺服器下載範例 import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; import java.net.URLConnection; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; @Path("/Purchase") public class File {     @GET   @Path("File/{FileName}")   @Produces(MediaType.APPLICATION_OCTET_STREAM + "; charset=UTF-8")   public Response getFile2(           @PathParam("FileName") String FileName   ) throws MalformedURLException, IOException  {     //遠端取檔案下載     URL url = new URL("http://www.example.com/files/" + FileName);     URLConnection uc = url.openConnection();     Response.ResponseBuilder response = Response.ok((Object) uc.getInputStream());     response.header("Content-Disposition", "attachment; filename=" + FileName);     return response.build();  

[API Server]jersey 檔案多檔上傳

1. POM     <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>     <dependency>       <groupId>org.glassfish.jersey.media</groupId>       <artifactId>jersey-media-multipart</artifactId>       <version>2.17</version>     </dependency> 2.上傳網頁 <html>   <head>     <title<TODO supply a title</title>     <meta charset="UTF-8">     <meta name="viewport" content="width=device-width, initial-scale=1.0">   </head>   <body>     <form action="API/file/MultiUpload&

[API Server]jersey 檔案上傳

1. POM           org.glassfish.jersey.containers       jersey-container-servlet       2.17                  org.glassfish.jersey.containers       jersey-container-servlet-core       2.17               org.glassfish.jersey.media       jersey-media-multipart       2.17     2.上傳網頁 <html>   <head>     <title>TODO supply a title</title>     <meta charset="UTF-8">     <meta name="viewport" content="width=device-width, initial-scale=1.0">   </head>   <body>     <form action="API/file/upload" method="post" enctype="multipart/form-data" >       <p>         Select a file : <input type="file" name="file" />       </p>       <input type="submit" value="Upload It" />     </form>       </body> </html> 3.API Server 設定 import javax.ws.rs.ApplicationPath; import

[angularjs]Error: $compile:multidir Multiple Directive Resource Contention 解決方式

官方文件 https://docs.angularjs.org/error/$compile/multidir 官方文件上說的事你宣告了兩個相同定義的directive 問題出在 directive   restrict: 'AE' 例如 這時候region跟school的directive定義為AE 那麼在學校tag也有個region他就傻傻分不清楚就壞掉囉OTZ 解決的方式是將directive的restrict改為E(Element)定義   restrict: 'E' 就可以解決重複定義的問題

[web] 網頁圖片 CSS Sprites、DataURI、Web Font 簡單比較及工具

CSS Sprites, DataURI 和 Icon-fonts 這三者都 可以用於網頁小圖示上。 這三者都可以用於減少網頁上的 request ,使網頁變快一些。 下列式分析 CSS Sprites 概述 : 就是把所有的小圖示變成一張大圖,再利用 CSS 定位方式去找到該圖片並顯示 優點 : 圖片可彩色 缺點 : 大小固定,重新作大圖很麻煩,維護不易 瀏覽器 : IE8+ 工具網站 : http://csssprites.com/ DataURI 概述 : 將圖片已 base64 作編碼,網站便會將他解譯成圖片 優點 : 圖片可彩色,不需再建立連線拉圖片 缺點 :IE8+ (IE8 有限制 32KB 大小 ) 工具網站 : http://www.base64-image.de/ Web Font 概述 : 字型本身就是圖案,所以利用字型檔 (ttf/woff/eot) 將圖片放置在對應的文字內 優點 : 因轉成文字,所以可以對圖片下 CSS( 但 CSS 仍受該 CSS 是否支援瀏覽器影響 ) 缺點 : 單色 工具網站 : http://icomoon.io/app/#/select

[javascript] JS 物件陣列篩選 update es6 version

用法如下 var School = [   {ID:1,Name:'台南市和順國中'},   {ID:2,Name:'台南市安順國中'},   {ID:3,Name:'台南市安南國中'}, ]; var filterSchool = []; filterSchool = School.filter(function (element, index, array) {  var patt1 = new RegExp('安');  return patt1.test(element.Name); }); console.log(filterSchool) -- 更新ES6寫法 constSchool = [   {ID:1,Name:'台南市和順國中'},   {ID:2,Name:'台南市安順國中'},   {ID:3,Name:'台南市安南國中'}, ]; let filterSchool = []; let keyword = '安'; filterSchool = School.filter( (element, index, array) => {  const patt1 = new RegExp(this.keyword );  return patt1.test(element.Name); }); 補充 RegExp 正規表示式 正規表示式 Regular Expression

[java]BIG5 字集判斷

前言,不是每個系統都支援UTF-8 UTF8的系統但要把資料拋入BIG5的系統內,如何讓使用者一看就知道字會有問題。 可以使用下面這段程式碼去判斷 請注意,這裡不另外處理補完計畫的字是否正常顯示 程式構想:http://blog.darkthread.net/blogs/darkthreadtw/archive/2007/04/21/733.aspx 原本是想說用字碼去判斷,但怪怪的 SOURSE: http://zh.wikipedia.org/wiki/%E5%A4%A7%E4%BA%94%E7%A2%BC //BIG5有定義的字 String testString = "峰"; //BIG5沒定義的UTF-8字集 //String testString = "峯"; //罕用字(3Byte呈現一個字UTF8字碼217E5) //String testString = "𡟥"; //BIUG5 自訂字FA40等自定義字集 //String testString = "";     String[] stringArray = testString.split("");     for (int i = 1; i < stringArray.length; i++) {       System.out.println(stringArray[i]);       //使用BIG5編碼再用UTF-8還原若有錯誤會顯示問號       String str = new String(stringArray[i].getBytes("BIG5"), "UTF-8");       if(str.equals("?")){         System.out.println(stringArray[i] + "非BIG5字集");       }     }