發表文章

jQuery Validation Regex 密碼判斷

資料來源參考網路,備份留存供自己參考用:) Regex: 判斷是否包含a-z (?=.*[a-z]) 判斷是否包含A-Z (?=.*[A-Z]) 判斷是否包含0-9 (?=.*[0-9]) 判斷特殊字元 ^[^~!@#$%^&*()_+]+$ Method:     //需包含小寫英文     jQuery.validator.addMethod("passwordformat_az", function (element) {       var patt1 = new RegExp("(?=.*[a-z])");       return patt1.test(element);     }, '該欄位需包含小寫英文');         //需包含大寫英文     jQuery.validator.addMethod("passwordformat_AZ", function (element) {       var patt1 = new RegExp("(?=.*[A-Z])");       return patt1.test(element);     }, '該欄位需包含大寫英文');     //需包含數字     jQuery.validator.addMethod("passwordformat_09", function (element) {       var patt1 = new RegExp("(?=.*[0-9])");       return patt1.test(element);     }, '該欄位需包含數字');       //不可包含~!@#$%^&*()_+     jQuery.validator.ad...

angular ajax file upload

請看程式上面的注解囉。 找資料很困難,查到怎麼做還蠻簡單=_= HTML <input id="file" name="file" type="file"  /> <input type="button" value="上傳2" ng-click="upload()"/> JS(Controller)  //檔案上傳函數 $scope.upload = function () {   //取得所選的上傳檔案 var file = document.getElementById('file').files[0];   //使用formData去包資料 var formData = new FormData();   //input name , 檔案/資料 formData.append("file", file); $http({  method: 'POST',  url: "Pathangul",  headers: {'Content-Type': undefined},  data: formData }).success(function (data) {  console.log(data); }).error(function () {  alert("error"); }); };

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=" + FileNam...

[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>   ...

[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" />  ...

[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' 就可以解決重複定義的問題