报错Error writing to serve
a994862495 发布于2017-12 浏览:4371 回复:12
0
收藏

java.io.IOException: Error writing to server
at sun.net.www.protocol.http.HttpURLConnection.writeRequests(HttpURLConnection.java:699)
at sun.net.www.protocol.http.HttpURLConnection.writeRequests(HttpURLConnection.java:711)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1567)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1474)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254)
at com.tz.IOPdemo.sysmanage.utils.HttpUtil.post(HttpUtil.java:48)
at com.facelogin.action.LoginAction.doPost(LoginAction.java:42)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:94)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:502)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1132)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:684)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2527)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2516)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)

以上是问题

下面是代码

package com.facelogin.action;

import java.io.IOException;
import java.net.URLEncoder;
import java.util.List;
import java.util.Map;

import javax.servlet.annotation.WebServlet;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.facelogin.util.DbUtil;
import com.tz.IOPdemo.sysmanage.utils.GetToken;
import com.tz.IOPdemo.sysmanage.utils.HttpUtil;
//https://aip.baidubce.com/rest/2.0/face/v2/match
@WebServlet("/Login")
public class LoginAction extends HttpServlet{
private static final String APP_ID="10381976";
private static final String APP_KEY="wYGVqhiCG8VUNixZQqDBNG2G";
private static final String SECRET_KEY="GRteakl2gL7KrUgM2TaGomlNoM5SaXd2";
private static String accessToken;
private static final String MATCH_URL = "https://aip.baidubce.com/rest/2.0/face/v2/match";
static{
accessToken = GetToken.getToken(APP_KEY, SECRET_KEY);
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
String faceBase = req.getParameter("faceBase");
System.out.println(faceBase);
//从数据库取出数据
String sql = "select base64 from user where id=?";
List> results = DbUtil.queryForList(sql, 1);
//System.out.println(results);
//进行对比
Map map = results.get(0);
String dbBase = (String) map.get("base64");
//参数拼接
String params = URLEncoder.encode("images", "UTF-8")+"="+URLEncoder.encode(faceBase+","+ dbBase, "UTF-8");
try {
String result = HttpUtil.post(MATCH_URL, dbBase, params);
System.out.println(result);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}

收藏
点赞
0
个赞
共12条回复 最后由goJhou回复于2017-12
#13goJhou回复于2017-12
#12 a994862495回复
感谢三楼的老铁 !参数传错了,注意百度云api中的参数!!!!!! 三楼正解!!!!
展开

能解决你的问题就好。来,一起参见加瓦殿下

0
#12a994862495回复于2017-12

感谢三楼的老铁 !参数传错了,注意百度云api中的参数!!!!!!

三楼正解!!!!

0
#11a994862495回复于2017-12
#6 goJhou回复
臣参见加瓦殿下

已解决,感谢老铁们!

0
#10a994862495回复于2017-12
#8 用户已被禁言回复
如果解决 记得在帖子里面评论说明解决方法哦

感谢老铁!!!已经解决啦!!!!!!!就是参数传错了会发生Error writing to serve服务器写入失败

 

0
#9goJhou回复于2017-12
#7 用户已被禁言回复
。。。。。。

哈哈哈哈你是不是给自己点赞的hhh

1
#8用户已被禁言回复于2017-12
#5 a994862495回复
感谢老铁提醒等会看看

如果解决 记得在帖子里面评论说明解决方法哦

1
#7用户已被禁言回复于2017-12
#6 goJhou回复
臣参见加瓦殿下

。。。。。。

1
#6goJhou回复于2017-12
#3 用户已被禁言回复
String result = HttpUtil.post(MATCH_URL, dbBase, params);参数有问题吧。 如果是用百度的httputil工具类 参数是url accesstoken param 看你的dbBase并不是accesstoken
展开

臣参见加瓦殿下

2
#5a994862495回复于2017-12
#3 用户已被禁言回复
String result = HttpUtil.post(MATCH_URL, dbBase, params);参数有问题吧。 如果是用百度的httputil工具类 参数是url accesstoken param 看你的dbBase并不是accesstoken
展开

感谢老铁提醒等会看看

0
#4a994862495回复于2017-12
#2 goJhou回复
你把你ak sk公开了,小伙子

没事换一下就可以啦

0
#3用户已被禁言回复于2017-12

String result = HttpUtil.post(MATCH_URL, dbBase, params);参数有问题吧。

如果是用百度的httputil工具类 参数是url accesstoken param

看你的dbBase并不是accesstoken

4
#2goJhou回复于2017-12

你把你ak sk公开了,小伙子

1
TOP
切换版块