Tag - restful

jersey html5 文件上传 FormData restful    2017-07-12 16:08:46    38

本文主要使用jersey1.x,结合html5的FormData对象来进行多文件提交示例讲解

FormData

FormData对象是html5的一个对象,目前的一些主流的浏览器都已经兼容。IE8及以下是不支持FormData的。FormData还支持困扰众多开发者已久的ajax的上传文件,以前我们上传文件,需要写一个表单直接刷新提交,但是这里不需要了。

代码示例

html

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <script src="js/jquery.js" type="text/javascript"></script>
  6. <script type="text/javascript">
  7. function test(){
  8. var form = new FormData(document.getElementById("form1"));
  9. $.ajax({
  10. url:"http://192.168.2.8:8066/file/multiFiles/",
  11. type:"post",
  12. data:form,
  13. processData:false,
  14. contentType:false,
  15. success:function(data){
  16. alert("pass");
  17. },
  18. error:function(e){
  19. alert("错误!!");
  20. }
  21. });
  22. }
  23. </script>
  24. </head>
  25. <body>
  26. <form id
java ws.rs restful    2017-04-28 16:21:43    389

错误信息

  1. Java.lang.AbstractMethodError: javax.ws.rs.core.UriBuilder.uri(Ljava/lang/String;)Ljavax/ws/rs/core/UriBuilder;
  2. at javax.ws.rs.core.UriBuilder.fromUri(UriBuilder.java:119)
  3. at com.sun.jersey.spi.Container.servlet.ServletContainer.service(ServletContainer.java:669)
  4. at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
  5. at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
  6. at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  7. at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)
  8. at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
  9. at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
  10. at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
  11. at org.apache.shiro.subject.support.DelegatingSubject.execute(Delega
2/2