net::ERR_CONNECTION_RESET

现在开发的一个项目,原来连接是可以点的,所有ajax的请求,今天都挂了,但是常规的可以,试过很多浏览器,只有火狐可以,其他都不行啊
求大神指点

1个回答

zxj0905094127
zxj0905094127 他这个是只有Ajax请求会这样,其他不会,另外火狐也不会报错
大约 3 年之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
webview 打开网页出现net::err_connection_reset
同样的网址 用手机浏览器可以正常打开 用webview打开就出现net::err_connection_reset错误 这是怎么回事? 该怎么解决?
Chrome浏览器报错net::ERR_CONNECTION_RESET
基于https的PUT,DELETE请求 报错:net::ERR_CONNECTION_RESET, GET和POST可以正常请求,另外新建的http服务,然后PUT,DELETE 也可以正常请求,(SSL证书没过期,服务用的tomcat7.0), 以下两种方法试过了:1、server.xml 里的readonly设置为false 2、在web.xml里加跨域过滤器,还是不行。请教各位大神,是否有可能是服务器配置限制了 PUT,DELETE请求,怎么排查问题呢?
office web apps部署后预览测试报错【net::ERR_CONNECTION_RESET 200】
# 部署了office web apps后 # # 预览 …/op/view.aspx成功 # # ![图片说明](https://img-ask.csdn.net/upload/201902/26/1551173356_455043.png) # # # 预览 …/hosting/discovery成功 # # # ![图片说明](https://img-ask.csdn.net/upload/201902/26/1551173484_869546.png) # # # 但是一旦在 view.aspx页面中输入文件地址,CreateLink创建链接之后,点击'Test the link'在新标签页打开创建的文件预览链接,一直显示 We‘re fetching your file…… # # # 浏览器控制台报错net::ERR_CONNECTION_RESET 200 连接被重置 # # # ![图片说明](https://img-ask.csdn.net/upload/201902/26/1551173665_636239.png) # # # 这到底是为什么吗? # # 在网上搜了很多相关解决方法,但是有提到这种问题的,没有找到一个解决的说明,麻烦帮忙看一下是什么原因造成的吧
chrome关于ERR_CONNECTION_RESET
chrome关于ERR_CONNECTION_RESET错误怎么解决
H5 <video>无法播放问题
我通过mp4链接可以从网站上下载mp4视频,但是通过H5 <video>无法播放并提示: ``` net::ERR_CONNECTION_RESET ``` 这是什么原因呢?
<video>无法播放iis7上的mp4视频
我通过`mp4`链接地址可以从网站上下载下来视频,但是当我将链接添加到`<video>`中时,视频无法播放,提示:`net::ERR_CONNECTION_RESET`。提前说明`mp4`编码格式是`H264`,而且`MIME`中也添加了`.mp4 video/mp4`。这会是什么原因呢?
android Webview ERR_CONTENT_DECODING_FAILED
重写onReceivedError 监听到description.tostring 可能会报ERR_CONTENT_DECODING_FAILED和ERR_CONNECTION_RESET 是什么问题;因为webview是调网页paypal支付;不同的国家显示的语言也不同;
android 网页集成PayPal支付
本地测试没有问题,但是正式 有时onReceivedError()监听可能会报ERR_CONTENT_DECODING_FAILED和ERR_CONNECTION_RESET;是什么问题有遇到过吗 支付的成功率低
android调webservice出现 (Connection reset by peer)
sunnyinfo.myapplication D/IOException: +++++++++++++++++++++++java.net.SocketException: recvfrom failed: ECONNRESET (Connection reset by peer) 03-14 17:51:27.073 20045-20211/com.sunnyinfo.myapplication W/System.err: java.net.SocketException: recvfrom failed: ECONNRESET (Connection reset by peer) 03-14 17:51:27.073 20045-20211/com.sunnyinfo.myapplication W/System.err: at libcore.io.IoBridge.maybeThrowAfterRecvfrom(IoBridge.java:592) 03-14 17:51:27.073 20045-20211/com.sunnyinfo.myapplication W/System.err: at libcore.io.IoBridge.recvfrom(IoBridge.java:556) 03-14 17:51:27.073 20045-20211/com.sunnyinfo.myapplication W/System.err: at java.net.PlainSocketImpl.read(PlainSocketImpl.java:485) 03-14 17:51:27.073 20045-20211/com.sunnyinfo.myapplication W/System.err: at java.net.PlainSocketImpl.access$000(PlainSocketImpl.java:37) 03-14 17:51:27.073 20045-20211/com.sunnyinfo.myapplication W/System.err: at java.net.PlainSocketImpl$PlainSocketInputStream.read(PlainSocketImpl.java:237) 03-14 17:51:27.073 20045-20211/com.sunnyinfo.myapplication W/System.err: at com.android.okio.Okio$2.read(Okio.java:113) 03-14 17:51:27.073 20045-20211/com.sunnyinfo.myapplication W/System.err: at com.android.okio.RealBufferedSource.indexOf(RealBufferedSource.java:147) 03-14 17:51:27.073 20045-20211/com.sunnyinfo.myapplication W/System.err: at com.android.okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:94) 03-14 17:51:27.073 20045-20211/com.sunnyinfo.myapplication W/System.err: at com.android.okhttp.internal.http.HttpConnection.readResponse(HttpConnection.java:175) 03-14 17:51:27.073 20045-20211/com.sunnyinfo.myapplication W/System.err: at com.android.okhttp.internal.http.HttpTransport.readResponseHeaders(HttpTransport.java:101) 03-14 17:51:27.073 20045-20211/com.sunnyinfo.myapplication W/System.err: at com.android.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:616) 03-14 17:51:27.073 20045-20211/com.sunnyinfo.myapplication W/System.err: at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:379) 03-14 17:51:27.073 20045-20211/com.sunnyinfo.myapplication W/System.err: at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:323) 03-14 17:51:27.073 20045-20211/com.sunnyinfo.myapplication W/System.err: at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:491) 03-14 17:51:27.073 20045-20211/com.sunnyinfo.myapplication W/System.err: at org.ksoap2.transport.ServiceConnectionSE.getResponseCode(ServiceConnectionSE.java:103) 03-14 17:51:27.073 20045-20211/com.sunnyinfo.myapplication W/System.err: at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:197) 03-14 17:51:27.073 20045-20211/com.sunnyinfo.myapplication W/System.err: at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:118) 03-14 17:51:27.073 20045-20211/com.sunnyinfo.myapplication W/System.err: at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:113) 03-14 17:51:27.073 20045-20211/com.sunnyinfo.myapplication W/System.err: at com.sunnyinfo.myapplication.WebServiceUtils$2.run(WebServiceUtils.java:131) 03-14 17:51:27.073 20045-20211/com.sunnyinfo.myapplication W/System.err: at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422) 03-14 17:51:27.073 20045-20211/com.sunnyinfo.myapplication W/System.err: at java.util.concurrent.FutureTask.run(FutureTask.java:237) 03-14 17:51:27.073 20045-20211/com.sunnyinfo.myapplication W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 03-14 17:51:27.073 20045-20211/com.sunnyinfo.myapplication W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 03-14 17:51:27.073 20045-20211/com.sunnyinfo.myapplication W/System.err: at java.lang.Thread.run(Thread.java:818) ``` ```
急急急。。Android 用wifi,3G网络访问报不同错
代码: public luntan_ResultComment selectFriend(){ luntan_ResultComment se_friend=new luntan_ResultComment(); final String url="http://169.254.10.92:8080/wancaiweb/SelectFriend"; try { urlConnection=new URL(url).openConnection(); urlConnection.setRequestProperty("connection","close"); inputStream = urlConnection.getInputStream(); String result=readStream(inputStream); try { JSONObject jsonObject=new JSONObject(result); se_friend.setTotal(jsonObject.getInt("total")); se_friend.setJsonArray(jsonObject.getJSONArray("comment")); } catch (JSONException e) { e.printStackTrace(); } } catch (IOException e) { e.printStackTrace(); } return se_friend; } 我的数据库是SQL2008,服务器是MyEclipse+Tomcat 我之间在学校是可以正常访问的,但是到家里就不能访问了 wifi访问报错: 07-20 20:59:42.410 14500-14657/java.net.SocketTimeoutException: failed to connect to /169.254.10.92 (port 8080) after 90000ms 07-20 20:59:42.410 14500-14657/com.example.wancai.Activity W/System.err: at libcore.io.IoBridge.connectErrno(IoBridge.java:176) 07-20 20:59:42.411 14500-14657/com.example.wancai.Activity W/System.err: at libcore.io.IoBridge.connect(IoBridge.java:112) 07-20 20:59:42.411 14500-14657/com.example.wancai.Activity W/System.err: at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:192) 07-20 20:59:42.411 14500-14657/com.example.wancai.Activity W/System.err: at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:459) 07-20 20:59:42.412 14500-14657/com.example.wancai.Activity W/System.err: at java.net.Socket.connect(Socket.java:857) 07-20 20:59:42.412 14500-14657/com.example.wancai.Activity W/System.err: at libcore.net.http.HttpConnection.<init>(HttpConnection.java:76) 07-20 20:59:42.412 14500-14657/com.example.wancai.Activity W/System.err: at libcore.net.http.HttpConnection.<init>(HttpConnection.java:50) 07-20 20:59:42.412 14500-14657/com.example.wancai.Activity W/System.err: at libcore.net.http.HttpConnection$Address.connect(HttpConnection.java:340) 07-20 20:59:42.413 14500-14657/com.example.wancai.Activity W/System.err: at libcore.net.http.HttpConnectionPool.get(HttpConnectionPool.java:87) 07-20 20:59:42.413 14500-14657/com.example.wancai.Activity W/System.err: at libcore.net.http.HttpConnection.connect(HttpConnection.java:128) 07-20 20:59:42.413 14500-14657/com.example.wancai.Activity W/System.err: at libcore.net.http.HttpEngine.openSocketConnection(HttpEngine.java:316) 07-20 20:59:42.413 14500-14657/com.example.wancai.Activity W/System.err: at libcore.net.http.HttpEngine.connect(HttpEngine.java:311) 07-20 20:59:42.414 14500-14657/com.example.wancai.Activity W/System.err: at libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:290) 07-20 20:59:42.414 14500-14657/com.example.wancai.Activity W/System.err: at libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:240) 07-20 20:59:42.414 14500-14657/com.example.wancai.Activity W/System.err: at libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:292) 07-20 20:59:42.414 14500-14657/com.example.wancai.Activity W/System.err: at libcore.net.http.HttpURLConnec 3G访问报错: java.net.SocketException: recvfrom failed: ECONNRESET (Connection reset by peer) 07-20 20:57:12.475 10200-13347/com.example.wancai.Activity W/System.err: at libcore.io.IoBridge.maybeThrowAfterRecvfrom(IoBridge.java:598) 07-20 20:57:12.475 10200-13347/com.example.wancai.Activity W/System.err: at libcore.io.IoBridge.recvfrom(IoBridge.java:560) 07-20 20:57:12.479 10200-13347/com.example.wancai.Activity W/System.err: at java.net.PlainSocketImpl.read(PlainSocketImpl.java:490) 07-20 20:57:12.480 10200-13347/com.example.wancai.Activity W/System.err: at java.net.PlainSocketImpl.access$000(PlainSocketImpl.java:46) 07-20 20:57:12.482 10200-13347/com.example.wancai.Activity W/System.err: at java.net.PlainSocketImpl$PlainSocketInputStream.read(PlainSocketImpl.java:240) 07-20 20:57:12.482 10200-13347/com.example.wancai.Activity W/System.err: at java.io.InputStream.read(InputStream.java:163) 07-20 20:57:12.483 10200-13347/com.example.wancai.Activity W/System.err: at java.io.BufferedInputStream.fillbuf(BufferedInputStream.java:142) 07-20 20:57:12.490 10200-13347/com.example.wancai.Activity W/System.err: at java.io.BufferedInputStream.read(BufferedInputStream.java:227) 07-20 20:57:12.491 10200-13347/com.example.wancai.Activity W/System.err: at libcore.io.Streams.readAsciiLine(Streams.java:201) 07-20 20:57:12.500 10200-13347/com.example.wancai.Activity W/System.err: at libcore.net.http.HttpEngine.readResponseHeaders(HttpEngine.java:573) 07-20 20:57:12.501 10200-13347/com.example.wancai.Activity W/System.err: at libcore.net.http.HttpEngine.readResponse(HttpEngine.java:821) 07-20 20:57:12.502 10200-13347/com.example.wancai.Activity W/System.err: at libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:293) 07-20 20:57:12.502 10200-13347/com.example.wancai.Activity W/System.err: at libcore.net.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:185) 07-20 20:57:12.502 10200-13347/com.example.wancai.Activity W/System.err: at com.example.wancai.InternetData.Friend_Data.selectFriend(Friend_Data.java:39) 07-20 20:57:12.502 10200-13347/com.example.wancai.Activity W/System.err: at com.example.wancai.Discover.VerifyFriendNoti.getServerMessage(VerifyFriendNoti.java:165) 07-20 20:57:12.503 10200-13347/com.example.wancai.Activity W/System.err: at com.example.wancai.Discover.VerifyFriendNoti$MessageThrad.run(VerifyFriendNoti.java:107) 07-20 20:57:12.503 10200-13347/com.example.wancai.Activity W/System.err: Caused by: libcore.io.ErrnoException: recvfrom failed: ECONNRESET (Connection reset by peer) 07-20 20:57:12.504 10200-13347/com.example.wancai.Activity W/System.err: at libcore.io.Posix.recvfromBytes(Native 不知道为什么会报这种错,大神帮帮我
Java WEB 连接数据库的登录界面失败?
使用Eclipse做登陆界面,连接MySQL 8.0,测试过连接数据库应该是成功的,可能是struts配置有问题,新手不知道问题出在哪里,请帮忙看一下代码,我标注几个我可能出问题又不知道怎么改的地方 //login.jsp //此处可能是表单中form的action属性有问题? ``` <%@ page contentType="text/html; charset=gb2312" language="java"%> <html> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <head> <title>图书馆管理系统</title> <link href="CSS/style.css" rel="stylesheet"> <script language="javascript"> function check(form){ if (form.name.value==""){ alert("请输入用户名称");form.name.focus();return false; } if (form.pwd.value==""){ alert("请输入密码");form.pwd.focus();return false; } } </script> </head> <body> <table width="1000" border="0" align="center" cellpadding="0" cellspacing="0" class="tableBorder"> <tr> <td width="1000" height="545" align="center" background="Images/login.png"> <table width="1000" height="345" aligh="center" ></table> <form name="form1" method="post" action="manager.do?action=login"> <table width="400" height="200" align="left"> <tr> <td height="37" style="width: 128px; "></td> <td height="37" width="50"> 用户名</td> <td height="37" width="150"> <input name="name" type="text" class="logininput" id="name" size="27"> </td> </tr> <tr> <td height="37" style="width: 128px; "></td> <td height="37" width="50"> 密码 </td> <td height="37" width="150"> <input name="pwd" type="text" class="logininput" id="pwd" size="27"> </td> </tr> <tr> <td height="37" style="width: 128px; "></td> <td height="37" width="50"></td> <td height="37" width="200"> <input name="Submit" type="submit" class="btn_grey" value="确定" onClick="return check(form1)"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input name="Submit3" type="reset" class="btn_grey" value="重置"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input name="Submit2" type="button" class="btn_grey" value="关闭" onClick="window.close();"> </td> </tr> </table> </form> </td> <tr> <td align="center" height="50" bgcolor="#3A3A3A" class="word_login">CopyRight &copy; 2019版权所有 xx图书馆<br> </td> </tr> </table> </body> </html> ``` //Manager.java ``` package com.action; import org.apache.struts.action.*; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.actionForm.ManagerForm; import com.dao.ManagerDAO; import javax.servlet.http.HttpSession; public class Manager extends Action { private ManagerDAO managerDAO = null; public Manager() { this.managerDAO = new ManagerDAO(); } public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { String action = request.getParameter("action"); // System.out.println("获取的查询字符串:" + action); if (action == null || "".equals(action)) { return mapping.findForward("error"); } else if ("login".equals(action)) { return managerLogin(mapping, form, request, response); } request.setAttribute("error", "操作失败!"); return mapping.findForward("error"); } // 管理员身份验证 public ActionForward managerLogin(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { ManagerForm managerForm = (ManagerForm) form; //将接收到的表单信息强制转换成ActionForm类型 managerForm.setAd_name(managerForm.getAd_name()); managerForm.setAd_pwd(managerForm.getAd_pwd()); int ret = managerDAO.checkManager(managerForm); System.out.print("验证结果ret的值:" + ret); if (ret == 1) { //将登录到系统的管理员名称保存到session HttpSession session = request.getSession(); session.setAttribute("manager", managerForm.getAd_name()); return mapping.findForward("managerLoginok"); } else { request.setAttribute("error", "您输入的管理员名称或密码错误!"); return mapping.findForward("error"); } } } ``` //ManagerForm ``` package com.actionForm; import org.apache.struts.action.ActionForm; public class ManagerForm extends ActionForm { private int ad_id; private String ad_name; private String ad_pwd; public ManagerForm() { } public int getAd_id() { return ad_id; } public void setAd_id(int ad_id) { this.ad_id=ad_id; } public String getAd_name() { return ad_name; } public void setAd_name(String ad_name) { this.ad_name=ad_name; } public String getAd_pwd() { return ad_pwd; } public void setAd_pwd(String ad_pwd) { this.ad_pwd=ad_pwd; } } ``` //ManagerDAO ``` package com.dao; import com.core.ChStr; import com.core.ConnDB; import java.util.*; import com.actionForm.ManagerForm; import java.sql.*; public class ManagerDAO { private ConnDB conn = new ConnDB(); //管理员身份验证 public int checkManager(ManagerForm managerForm) { int flag = 0; ChStr chStr=new ChStr(); String sql = "SELECT * FROM Ad_info where ad_name='" + chStr.filterStr(managerForm.getAd_name()) + "'"; ResultSet rs = conn.executeQuery(sql); try { if (rs.next()) { String pwd = chStr.filterStr(managerForm.getAd_pwd()); //获取输入的密码并过滤输入字符串中的危险字符 if (pwd.equals(rs.getString(3))) { flag = 1; } else { flag = 0; } }else{ flag = 0; } } catch (SQLException ex) { flag = 0; }finally{ conn.close(); } return flag; } } ``` //ConnDB ``` package com.core; import java.io.InputStream; import java.sql.*; import java.util.Properties; public class ConnDB { public Connection conn=null; public Statement stmt=null; public ResultSet rs=null; private static String propFileName="/com/connDB.properties"; private static Properties prop=new Properties(); private static String dbClassName="com.mysql.cj.jdbc.Driver"; private static String dbUrl="jdbc:mysql://223.80.110.29:3306/sys_test?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&zeroDateTimeBehavior=CONVERT_TO_NULL"; private static String dbUserName="root"; private static String dbPassword=""; //加载资源文件 public ConnDB() { try { InputStream in=getClass().getResourceAsStream(propFileName); prop.load(in); dbClassName=prop.getProperty("DB_CLASS_NAME","com.mysql.cj.jdbc.Driver"); dbUrl=prop.getProperty("DB_URL","jdbc:mysql://localhost:3306/db_librarysys?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&zeroDateTimeBehavior=CONVERT_TO_NULL"); dbUserName=prop.getProperty("DB_USERNAME"); dbPassword=prop.getProperty("DB_PASSWORD"); } catch(Exception e){ e.printStackTrace(); } } public static Connection getConnection() { Connection conn=null; try { //加载数据库驱动 Class.forName(dbClassName); conn=DriverManager.getConnection(dbUrl,dbUserName,dbPassword); } catch(Exception ee) { ee.printStackTrace(); } if(conn==null) { System.err.println("警告:DbConnectionManager.getConnection()获得数据库链接失败.\r\n\r\n链接类型:"+dbClassName+"\r\n链接位置:"+dbUrl); } return conn; } //执行查询语句 public ResultSet executeQuery(String sql) { try { conn=getConnection(); stmt=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY); /*ResultSet.CONCUR_READ_ONLY 不能用结果集更新数据库中的表 ResultSet.TYPE_SCROLL_INSENSITIVE 结果集的游标可以上下移动,当数据库变化时,当前结果集不变。 */ rs=stmt.executeQuery(sql); } catch(SQLException ex){ System.err.println(ex.getMessage()); } return rs; } //执行更新操作 添加修改删除数据 public int executeUpdate(String sql) { int result=0;//更新的行数 try { conn=getConnection(); stmt=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY); result=stmt.executeUpdate(sql); }catch(SQLException ex) { result=0; } return result; } public void close() { try { if(rs!=null) { rs.close(); } if(stmt!=null) { stmt.close(); } if(conn!=null) { conn.close(); } }catch(Exception e) { e.printStackTrace(System.err); } } } ``` //struts-config ``` <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd"> <struts-config> <form-beans> <form-bean name="managerForm" type="com.actionForm.ManagerForm" /> <form-bean name="ParameterForm" type="com.actionForm.ParameterForm" /> </form-beans> <action-mappings type="org.apache.struts.action.ActionMapping"> <action name="managerForm" path="/manager" scope="request" type="com.action.Manager" validate="true"> <forward name="managerLoginok" path="/main.jsp" /> <forward name="error" path="/error.jsp" /> </action> <action name="ParameterForm" path="/parameter" scope="request" type="com.action.Parameter" validate="true"> <forward name="error" path="/error.jsp" /> <forward name="parametermodify" path="/parameter_ok.jsp?para=2" /> <forward name="parametermodifyQuery" path="/parameter_modify.jsp" /> </action> </action-mappings> <message-resources parameter="com.wgh.struts.ApplicationResources" /> </struts-config> ```
android 中使用HttpURLConnection报错
代码如下: ``` private String HttpConnection(String urlString) throws IOException { HttpURLConnection urlConnection = null; BufferedInputStream in = null; final URL url; try { url = new URL(urlString); urlConnection = (HttpURLConnection) url.openConnection(); urlConnection.setConnectTimeout(5000); in = new BufferedInputStream(urlConnection.getInputStream()); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } InputStreamReader isr; String result=""; String line=""; try { if (in!=null){ isr=new InputStreamReader(in,"utf-8"); BufferedReader br=new BufferedReader(isr); while ((line=br.readLine())!=null){ result+=line; } } } catch (UnsupportedEncodingException e) { e.printStackTrace(); } urlConnection.disconnect(); return result; } ```使用移动网络就会报这个09-07 09:47:24.705: W/System.err(21672): java.net.SocketException: recvfrom failed: ECONNRESET (Connection reset by peer)异常,然而如果用wifi网络就没有问题,把网址直接输入浏览器中打来也没有问题。这是怎么回事呢
windows 重叠IO 命名管道程序疑问?
我写了一个命名管道通信例子,但是现在有两个疑问? 疑问1 : 为什么我的程序只能由客户端向服务器发送数据,服务端不能向客户端发送数据呢?服务端显示发送成功,但是客户端相应的可读事件不能被触发。 疑问2 : 偶尔出现客户端向服务器发送数据的时候 前一两个包丢失。 服务端代码: ``` #include "stdafx.h" #include <windows.h> #include <stdio.h> #include <tchar.h> #include <strsafe.h> #define CONNECTING_STATE 3 #define READING_STATE 1 #define WRITING_STATE 2 #define INSTANCES 1 #define PIPE_TIMEOUT 5000 #define BUFSIZE 4096 typedef struct { OVERLAPPED oOverlap; HANDLE hPipeInst; } PIPEINST, *LPPIPEINST; VOID DisconnectAndReconnect(DWORD); BOOL ConnectToNewClient(HANDLE, LPOVERLAPPED); bool PostRecvRequest(LPPIPEINST hInst) { if (NULL == hInst) return false; char buf[1] = {0}; DWORD dwBytesReaded = 0; if (!ReadFile(hInst->hPipeInst, buf, 1, &dwBytesReaded, &hInst->oOverlap)) { DWORD err = GetLastError(); if (err != ERROR_IO_PENDING) { printf("client ReadFile error : %d \n", err); return false; } } return true; } bool IsNamedPipeCanRecv(LPPIPEINST hInst) { if (NULL == hInst) return false; if (WAIT_OBJECT_0 ==WaitForSingleObject(hInst->oOverlap.hEvent, INFINITE)) { return true; } ResetEvent(hInst->oOverlap.hEvent); return false; } DWORD WINAPI RecvThread(LPVOID param) { LPPIPEINST hInst = (LPPIPEINST) param; if (hInst) { while(1) { if (IsNamedPipeCanRecv(hInst)) { char buf[1024] = {0}; DWORD dwBytesReaded = 0; ReadFile(hInst->hPipeInst, buf, 1024, &dwBytesReaded, NULL); printf("Server recv : %s\n", buf); } PostRecvRequest(hInst); } } return 0; } PIPEINST Pipe[INSTANCES]; HANDLE hEvents[INSTANCES]; int _tmain(int argc, _TCHAR* argv[]) { LPTSTR lpszPipename = TEXT("\\\\.\\pipe\\mynamedpipe"); for (int i = 0; i < INSTANCES; i++) { // Create an event object for this instance. hEvents[i] = CreateEvent( NULL, // default security attribute TRUE, // manual-reset event TRUE, // initial state = signaled NULL); // unnamed event object if (hEvents[i] == NULL) { printf("CreateEvent failed with %d.\n", GetLastError()); return 0; } Pipe[i].oOverlap.hEvent = hEvents[i]; Pipe[i].hPipeInst = CreateNamedPipe( lpszPipename, // pipe name PIPE_ACCESS_DUPLEX | // read/write access FILE_FLAG_OVERLAPPED, // overlapped mode PIPE_TYPE_MESSAGE | // message-type pipe PIPE_READMODE_MESSAGE | // message-read mode PIPE_WAIT, // blocking mode INSTANCES, // number of instances BUFSIZE*sizeof(TCHAR), // output buffer size BUFSIZE*sizeof(TCHAR), // input buffer size PIPE_TIMEOUT, // client time-out NULL); // default security attributes if (Pipe[i].hPipeInst == INVALID_HANDLE_VALUE) { printf("CreateNamedPipe failed with %d.\n", GetLastError()); return 0; } ConnectToNewClient( Pipe[i].hPipeInst, &Pipe[i].oOverlap); } HANDLE hThread = CreateThread(0, 0, RecvThread, &Pipe[0], 0, 0); while (1) { char buf[1024]; scanf("%s", buf); DWORD dw; BOOL b = WriteFile(Pipe[0].hPipeInst, buf, strlen(buf), &dw, &Pipe[0].oOverlap); printf("send(%d:%d) : %s\n", dw, b, buf); } return 0; } VOID DisconnectAndReconnect(DWORD i) { // Disconnect the pipe instance. if (! DisconnectNamedPipe(Pipe[i].hPipeInst) ) { printf("DisconnectNamedPipe failed with %d.\n", GetLastError()); } // Call a subroutine to connect to the new client. ConnectToNewClient( Pipe[i].hPipeInst, &Pipe[i].oOverlap); } BOOL ConnectToNewClient(HANDLE hPipe, LPOVERLAPPED lpo) { BOOL fConnected, fPendingIO = FALSE; // Start an overlapped connection for this pipe instance. fConnected = ConnectNamedPipe(hPipe, lpo); // Overlapped ConnectNamedPipe should return zero. if (fConnected) { printf("ConnectNamedPipe failed with %d.\n", GetLastError()); return 0; } switch (GetLastError()) { // The overlapped connection in progress. case ERROR_IO_PENDING: fPendingIO = TRUE; break; // Client is already connected, so signal an event. case ERROR_PIPE_CONNECTED: if (SetEvent(lpo->hEvent)) break; // If an error occurs during the connect operation... default: { printf("ConnectNamedPipe failed with %d.\n", GetLastError()); return 0; } } return fPendingIO; } ``` 客户端代码 ``` #include "stdafx.h" #include <windows.h> #include <stdio.h> #include <conio.h> #include <tchar.h> #define BUFSIZE 512 typedef struct { OVERLAPPED oOverlap; HANDLE hPipeInst; } PIPEINST, *LPPIPEINST; bool PostRecvRequest(LPPIPEINST hInst) { if (NULL == hInst) return false; char buf[1] = {0}; DWORD dwBytesReaded = 0; if (!ReadFile(hInst->hPipeInst, buf, 1, &dwBytesReaded, &hInst->oOverlap)) { DWORD err = GetLastError(); if (err != ERROR_IO_PENDING) { // 109 管道已结束 printf("client ReadFile error : %d \n", err); return false; } } return true; } bool IsNamedPipeCanRecv(LPPIPEINST hInst) { if (NULL == hInst) return false; if (WAIT_OBJECT_0 ==WaitForSingleObject(hInst->oOverlap.hEvent, INFINITE)) { return true; } ResetEvent(hInst->oOverlap.hEvent); return false; } DWORD WINAPI RecvThread(LPVOID param) { LPPIPEINST hInst = (LPPIPEINST) param; if (hInst) { while(1) { if (IsNamedPipeCanRecv(hInst)) { char buf[1024] = {0}; DWORD dwBytesReaded = 0; ReadFile(hInst->hPipeInst, buf, 1024, &dwBytesReaded, NULL); printf("Client recv : %s\n", buf); } PostRecvRequest(hInst); } } return 0; } int _tmain(int argc, _TCHAR* argv[]) { PIPEINST Pipe; Pipe.oOverlap.hEvent = CreateEvent( NULL, // default security attribute TRUE, // manual-reset event FALSE, // initial state = signaled NULL); // unnamed event object LPTSTR lpvMessage=TEXT("Default message from client."); BOOL fSuccess = FALSE; DWORD dwMode; LPTSTR lpszPipename = TEXT("\\\\.\\pipe\\mynamedpipe"); if( argc > 1 ) lpvMessage = argv[1]; // Try to open a named pipe; wait for it, if necessary. while (1) { Pipe.hPipeInst = CreateFile( lpszPipename, // pipe name GENERIC_READ | GENERIC_WRITE, // read and write access 0, // no sharing NULL, // default security attributes OPEN_EXISTING, // opens existing pipe FILE_FLAG_OVERLAPPED, // default attributes NULL); // no template file // Break if the pipe handle is valid. if ( Pipe.hPipeInst != INVALID_HANDLE_VALUE) break; // Exit if an error other than ERROR_PIPE_BUSY occurs. if (GetLastError() != ERROR_PIPE_BUSY) { _tprintf( TEXT("Could not open pipe. GLE=%d\n"), GetLastError() ); return -1; } // All pipe instances are busy, so wait for 20 seconds. if ( ! WaitNamedPipe(lpszPipename, 20000)) { printf("Could not open pipe: 20 second wait timed out."); return -1; } } // The pipe connected; change to message-read mode. dwMode = PIPE_READMODE_MESSAGE | PIPE_WAIT; fSuccess = SetNamedPipeHandleState( Pipe.hPipeInst, // pipe handle &dwMode, // new pipe mode NULL, // don't set maximum bytes NULL); // don't set maximum time if ( ! fSuccess) { _tprintf( TEXT("SetNamedPipeHandleState failed. GLE=%d\n"), GetLastError() ); return -1; } // Send a message to the pipe server. PostRecvRequest(&Pipe); HANDLE hThread = CreateThread(0, 0, RecvThread, &Pipe, 0, 0); while (1) { char buf[1024]; scanf("%s", buf); DWORD dw; WriteFile(Pipe.hPipeInst, buf, strlen(buf), &dw, NULL); printf("send(%d) : %s\n", dw, buf); } return 0; } ```
socket connection resect
我写了一个传送报文的socket,正常情况下服务器端和客户端都没有问题,但是只要客户端在报错,服务器端就会报connection reset,理论上客户端的操作应该对服务器端没有影响才对啊 server [code="java"] package Work; import java.io.*; import java.net.*; import java.util.HashMap; public class SocketAPIServer extends Thread { /** * 报文拆解 返回报文体中的字段 * * @param rspPkgStr * 返回报文 * @return * @throws Exception */ public static HashMap<String, String> dissolveRspPkgBodyStr(String rspPkgStr) throws Exception { HashMap<String, String> hashMap = new HashMap<String, String>(); String sbody = rspPkgStr.substring(65); String[] abody = sbody.split("\\|"); for (int i = 0; i < abody.length; i++) { String sPair = abody[i]; String[] aPair = sPair.split("="); if (aPair.length == 2) { hashMap.put(sPair.split("=")[0], sPair.split("=")[1]); } else { hashMap.put(sPair.split("=")[0], ""); } } return hashMap; } /** * 报文拆解 返回报文头中的字段 * * @param rspPkgStr * @return * @throws Exception */ public static HashMap<String, String> dissolvePkgHeadStr(String rspPkgStr) throws Exception { HashMap<String, String> hashMap = new HashMap<String, String>(); String shead = rspPkgStr.substring(0, 65); hashMap.put("报文长度", shead.substring(0, 5)); // 0-5_报文长度 hashMap.put("ID号", shead.substring(5, 11)); // 6-11_ID号 hashMap.put("固定'0000'", shead.substring(11, 15)); // 12-15_固定"0000" hashMap.put("交易码", shead.substring(15, 25)); // 16-25_六个字符串的交易码 hashMap.put("客户经理号", shead.substring(25, 33)); // 26-33_客户经理号 hashMap.put("空格_01", shead.substring(33, 54)); // 34-54_空格 hashMap.put("空格_02", shead.substring(54, 65)); // 55-64空格 return hashMap; } /** * 建立socket连接,监听端口 * * @return */ public void run() { ServerSocket serverSocket = null; PrintWriter out = null; BufferedReader in = null; try { // 实例化监听端口 serverSocket = new ServerSocket(8888); } catch (IOException e) { System.err.println("Could not listen on port: 8888."); System.exit(1); } Socket incoming = null; try { while (true) { try { incoming = serverSocket.accept(); out = new PrintWriter(incoming.getOutputStream(), true); // 先将字节流通过 InputStreamReader 转换为字符流,之后将字符流放入缓冲之中 in = new BufferedReader(new InputStreamReader(incoming .getInputStream())); } catch (IOException e) { e.printStackTrace(); } // 提示信息 out.println("Hello! . . . "); out.flush(); // 没有异常的情况不断循环 while (true) { // 只有当有用户输入的时候才返回数据 String str = in.readLine(); // 当用户连接断掉时会返回空值 null if (str == null) { // 退出循环 break; } else { StringBuffer strh = new StringBuffer(); StringBuffer strb = new StringBuffer(); HashMap<String, String> mapHead = dissolvePkgHeadStr(str); for (String key : mapHead.keySet()) { strh.append(key); strh.append("="); strh.append(mapHead.get(key)); } HashMap<String, String> mapBody = dissolveRspPkgBodyStr(str); for (String key : mapBody.keySet()) { strb.append(key); strb.append("="); strb.append(mapBody.get(key)); } String str1 = strh.toString(); String str2 = strb.toString(); // 对用户输入字串加前缀 Echo:,将此信息打印到客户端 out.println("Echo: " + str); System.out.println("收到信息:"+str); //打印包头 for (String keyHead : mapHead.keySet()) { System.out.println(keyHead+"="+mapHead.get(keyHead)); out.println(keyHead+"="+mapHead.get(keyHead)); } //打印包体 for (String keyBody : mapBody.keySet()) { System.out.println(keyBody+"="+mapBody.get(keyBody)); out.println(keyBody+"="+mapBody.get(keyBody)); } out.println(str1); out.println(str2); out.flush(); } } } } catch (IOException e) { e.printStackTrace(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } public static void main(String[] args) throws IOException { Thread thread = new SocketAPIServer(); thread.setDaemon(true); thread.start(); while (true) { try { Thread.sleep(1000); } catch (Exception e) { e.printStackTrace(); return; } } } } [/code] client [code="java"] package Work; import java.io.*; import java.net.*; import java.util.HashMap; // 客户端程序 public class SocketAPIClient { /** * 输入报文头 * * @return str 报文头 */ public static String inputPkgHead() throws IOException { System.out.println("请输入报文长度"); String str1 = new BufferedReader(new InputStreamReader(System.in)) .readLine(); System.out.println("请输入ID号"); String str2 = new BufferedReader(new InputStreamReader(System.in)) .readLine(); System.out.println("请输入固定'0000'"); String str3 = new BufferedReader(new InputStreamReader(System.in)) .readLine(); System.out.println("请输入交易码"); String str4 = new BufferedReader(new InputStreamReader(System.in)) .readLine(); System.out.println("请输入客户经理号"); String str5 = new BufferedReader(new InputStreamReader(System.in)) .readLine(); String str = str1 + "," + str2 + "," + str3 + "," + str4 + "," + str5; return str; } /** * 追加一定数目的空格到字符传尾,使其符合特定的长度 * * @param s * 原始字段 * @param len * 定义长度 * @return */ private static String tailPad2Str(String s, int len) { int length = 0; if (s == null) { s = ""; } try { length = s.getBytes("gb18030").length; } catch (UnsupportedEncodingException e) { e.printStackTrace(); } if (length > len) { throw new IllegalArgumentException("STRING TOO LONG ..."); } StringBuffer buffer = new StringBuffer(); buffer.append(s); for (int i = 0; i < (len - length); i++) { buffer.append(' '); } return buffer.toString(); } /** * 根据 流水ID, 交易码 生成报文头 * * @param seqNo * @param tradeCode * @return * @throws IOException */ public static String composePkgHeadStr() throws IOException { StringBuffer buffer = new StringBuffer(); String t = inputPkgHead(); String[] s = t.split(","); buffer.append(tailPad2Str(s[0], 6)); // 0-5_报文长度 buffer.append(tailPad2Str(s[1], 6)); // 6-11_ID号 buffer.append(tailPad2Str(s[2], 4)); // 12-15_固定"0000" buffer.append(tailPad2Str(s[3], 10)); // 16-25_六个字符串的交易码 buffer.append(tailPad2Str(s[4], 8)); // 26-33_客户经理号 buffer.append(tailPad2Str("", 21)); // 34-54_空格 buffer.append(tailPad2Str("", 10)); // 55-64空格 return buffer.toString(); } /** * 生成报文体字符串 * * @param kcoll * @return * @throws IOException */ public static String composePkgBodyStr() throws IOException { StringBuffer buffer = new StringBuffer(); HashMap<String, String> map = new HashMap<String, String>(); // 输入报文体 while (true) { System.out.println("请输入Key"); String str1 = new BufferedReader(new InputStreamReader(System.in)) .readLine(); System.out.println("请输入Value"); String str2 = new BufferedReader(new InputStreamReader(System.in)) .readLine(); map.put(str1, str2); System.out.println("输入'ENTER'提交或回车继续输入"); String str3 = new BufferedReader(new InputStreamReader(System.in)) .readLine(); // 退出命令,equalsIgnoreCase() 是不区分大小写的比较 if (str3.trim().equalsIgnoreCase("ENTER")) break; } if (map == null || map.size() == 0) { throw new IllegalArgumentException("PKG BODY IS EMPTY .."); } else { for (String key : map.keySet()) { buffer.append(key); buffer.append("="); buffer.append(map.get(key)); buffer.append("|"); } } return buffer.toString(); } public static void main(String[] args) throws IOException { Socket echoSocket = null; PrintWriter out = null; BufferedReader in = null; try { echoSocket = new Socket("localhost", 8888); out = new PrintWriter(echoSocket.getOutputStream(), true); in = new BufferedReader(new InputStreamReader(echoSocket .getInputStream())); } catch (UnknownHostException e) { System.err.println("Don't know about host: localhost."); System.exit(1); } System.out.println(in.readLine()); String userInput = composePkgHeadStr() + composePkgBodyStr(); // 将客户端 Socket 输入流(既服务器端 Socket 的输出流)输出到标准输出上 out.println(userInput); System.out.println(in.readLine()); System.out.println(in.readLine()); System.out.println(in.readLine()); System.out.println(in.readLine()); out.close(); in.close(); System.out.println("输入'CLOSE'断开连接"); String strClose = new BufferedReader(new InputStreamReader(System.in)) .readLine(); // 退出命令,equalsIgnoreCase() 是不区分大小写的比较 if (strClose.trim().equalsIgnoreCase("CLOSE")) echoSocket.close(); } } [/code]
为什么设置了编码输出中文还是乱码,是文本框还有设置吗input怎么写的
<%@page import="edu.jmi.db.*" %> <%@page import="java.sql.*" %> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> </head> <body> <center> <% String str =null; //1设置解码 request.setCharacterEncoding("utf-8"); //2获取参数 str=request.getParameter("name"); String str1=request.getParameter("password"); String str2=request.getParameter("password2"); String str3=request.getParameter("mail"); System.out.println(str+str1+str2+str3); if(str==null){//如果初次加载页面,直接返回,不会执行下面存取数据库的代码 //return; }else{ //3存取数据库 //3.1获取数据库链接 Connection conn=DB.getConnection(); //3.2准备插入sql语句 String name=DB.validUser(str); if(name==null){ String sql="insert into user(name,password,email) values(?,?,?)"; PreparedStatement pst=conn.prepareStatement(sql);//执行sql语句 // pst.setInt(1,1); //id pst.setString(1,str);//name pst.setString(2,str1);//pass pst.setString(3,str3);//email if(str1.equals(str2)){ //3.3执行插入 int res=pst.executeUpdate(); System.out.println("插入结果是:"+res); pst.close(); conn.close(); session.setAttribute("usr", str); response.sendRedirect("regok.jsp"); }else{ session.setAttribute("errmsg", "密码和确认密码不一致"); } }else{ session.setAttribute("errmsg2", "用户名已存在,请重新输入"); } } String err = (String)session.getAttribute("errmsg"); if(err==null){ err=""; } String err2 = (String)session.getAttribute("errmsg2"); if(err2==null){ err2=""; } %> <%=err %> <%=err2 %> <form action="" > <p>用户名:<input type="text" value="" name="name"></p> <p>密码:<input type="password" value="" name="password"></p> <p>确认密码:<input type="password" value="" name="password2"></p> <p>邮箱:<input type="text" value="" name="mail"></p> <input type="submit" value="注册"> <input type="reset" value="重置"> </form> </center> </body> </html>
Tomcat7配置SSL证书之后浏览器访问显示连接被重置
* netstat -ntlp 之后 8080 和 443端口 都有 * 8080可以正常访问 * 443端口出现 无法访问此网站 连接已重置 * ERR_CONNECTION_RESET * 证书是阿里云购买的 下载下来两个文件 一个.pfx 一个是密码 * server.xml文件如下 ``` <?xml version='1.0' encoding='utf-8'?> <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <!-- Note: A "Server" is not itself a "Container", so you may not define subcomponents such as "Valves" at this level. Documentation at /docs/config/server.html --> <Server port="8005" shutdown="SHUTDOWN"> <Listener className="org.apache.catalina.startup.VersionLoggerListener" /> <!-- Security listener. Documentation at /docs/config/listeners.html <Listener className="org.apache.catalina.security.SecurityListener" /> --> <!--APR library loader. Documentation at /docs/apr.html --> <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" /> <!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html --> <Listener className="org.apache.catalina.core.JasperListener" /> <!-- Prevent memory leaks due to use of particular java/javax APIs--> <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" /> <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" /> <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" /> <!-- Global JNDI resources Documentation at /docs/jndi-resources-howto.html --> <GlobalNamingResources> <!-- Editable user database that can also be used by UserDatabaseRealm to authenticate users --> <Resource name="UserDatabase" auth="Container" type="org.apache.catalina.UserDatabase" description="User database that can be updated and saved" factory="org.apache.catalina.users.MemoryUserDatabaseFactory" pathname="conf/tomcat-users.xml" /> </GlobalNamingResources> <!-- A "Service" is a collection of one or more "Connectors" that share a single "Container" Note: A "Service" is not itself a "Container", so you may not define subcomponents such as "Valves" at this level. Documentation at /docs/config/service.html --> <Service name="Catalina"> <!--The connectors can use a shared executor, you can define one or more named thread pools--> <!-- <Executor name="tomcatThreadPool" namePrefix="catalina-exec-" maxThreads="150" minSpareThreads="4"/> --> <!-- A "Connector" represents an endpoint by which requests are received and responses are returned. Documentation at : Java HTTP Connector: /docs/config/http.html (blocking & non-blocking) Java AJP Connector: /docs/config/ajp.html APR (HTTP/AJP) Connector: /docs/apr.html Define a non-SSL HTTP/1.1 Connector on port 8080 --> <Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" /> <!-- A "Connector" using the shared thread pool--> <!-- <Connector executor="tomcatThreadPool" port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" /> --> <!-- Define a SSL HTTP/1.1 Connector on port 8443 This connector uses the BIO implementation that requires the JSSE style configuration. When using the APR/native implementation, the OpenSSL style configuration is required as described in the APR/native documentation --> <Connector port="443" protocol="org.apache.coyote.http11.Http11Protocol" maxThreads="150" SSLEnabled="true" scheme="https" secure="true" keystoreFile="/home/tomcat/apache-tomcat-7.0.94/cert/2095350_www.rumination.tech.pfx" keystoreType="PKCS12" keystorePass="hWD5bIfg" clientAuth="false" sslProtocol="TLS" /> <!-- Define an AJP 1.3 Connector on port 8009 --> <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" /> <!-- An Engine represents the entry point (within Catalina) that processes every request. The Engine implementation for Tomcat stand alone analyzes the HTTP headers included with the request, and passes them on to the appropriate Host (virtual host). Documentation at /docs/config/engine.html --> <!-- You should set jvmRoute to support load-balancing via AJP ie : <Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1"> --> <Engine name="Catalina" defaultHost="localhost"> <!--For clustering, please take a look at documentation at: /docs/cluster-howto.html (simple how to) /docs/config/cluster.html (reference documentation) --> <!-- <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/> --> <!-- Use the LockOutRealm to prevent attempts to guess user passwords via a brute-force attack --> <Realm className="org.apache.catalina.realm.LockOutRealm"> <!-- This Realm uses the UserDatabase configured in the global JNDI resources under the key "UserDatabase". Any edits that are performed against this UserDatabase are immediately available for use by the Realm. --> <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/> </Realm> <Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true"> <!-- SingleSignOn valve, share authentication between web applications Documentation at: /docs/config/valve.html --> <!-- <Valve className="org.apache.catalina.authenticator.SingleSignOn" /> --> <!-- Access log processes all example. Documentation at: /docs/config/valve.html Note: The pattern used is equivalent to using pattern="common" --> <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log." suffix=".txt" pattern="%h %l %u %t &quot;%r&quot; %s %b" /> </Host> </Engine> </Service> </Server> ```
后台做密码和确认密码,不一致给出了提示但数据还是输入了数据库怎么改
<%@page import="com.sun.corba.se.spi.orbutil.fsm.Guard.Result"%> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> <%@ page import= "edu.jmi.db.*" %> <%@ page import= "edu.jmi.dao.*" %> <%@ page import= "edu.jmi.model.*" %> <%@ page import= "java.sql.*" %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> </head> <style type="text/css"> </style> <body> <center> <% String str =null; //1设置解码 request.setCharacterEncoding("utf-8"); //2获取参数 str=request.getParameter("name"); String str1=request.getParameter("password"); String str2=request.getParameter("password2"); String str3=request.getParameter("mail"); System.out.println(str+str1+str2+str3); if(str==null){//如果初次加载页面,直接返回,不会执行下面存取数据库的代码 //return; }else{ //3存取数据库 //3.1获取数据库链接 Connection conn=DB.getConnection(); //3.2准备插入sql语句 String sql="insert into user(name,password,email) values(?,?,?)"; PreparedStatement pst=conn.prepareStatement(sql);//执行sql语句 // pst.setInt(1,1); //id pst.setString(1,str);//name pst.setString(2,str1);//pass pst.setString(3,str3);//email str1=request.getParameter("password"); str2=request.getParameter("password2"); if(str1.equals(str2)){ session.setAttribute("usr", str); response.sendRedirect("regok.jsp"); }else{ session.setAttribute("errmsg", "密码和确认密码不一致"); } String err = (String)session.getAttribute("errmsg"); if(err==null){ err=""; } //3.3执行插入 int res=pst.executeUpdate(); System.out.println("插入结果是:"+res); pst.close(); conn.close(); } %> <%=session.getAttribute("errmsg") %> <form action="" > <p>用户名:<input type="text" value="" name="name"></p> <p>密码:<input type="password" value="" name="password"></p> <p>确认密码:<input type="password" value="" name="password2"></p> <p>邮箱:<input type="text" value="" name="mail"></p> <input type="submit" value="注册"> <input type="reset" value="重置"> </form> </center> </body> </html>
界面上出现两个null,明明已经获取为空了为什么还是有,求解决
<%@page import="edu.jmi.db.*" %> <%@page import="java.sql.*" %> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> </head> <body> <center> <% String str =null; //1设置解码 request.setCharacterEncoding("utf-8"); //2获取参数 str=request.getParameter("name"); String str1=request.getParameter("password"); String str2=request.getParameter("password2"); String str3=request.getParameter("mail"); System.out.println(str+str1+str2+str3); if(str==null){//如果初次加载页面,直接返回,不会执行下面存取数据库的代码 //return; }else{ //3存取数据库 //3.1获取数据库链接 Connection conn=DB.getConnection(); //3.2准备插入sql语句 String dbpw=DB.validUser(str); if(dbpw==null){ String sql="insert into user(name,password,email) values(?,?,?)"; PreparedStatement pst=conn.prepareStatement(sql);//执行sql语句 // pst.setInt(1,1); //id pst.setString(1,str);//name pst.setString(2,str1);//pass pst.setString(3,str3);//email if(str1.equals(str2)){ //3.3执行插入 int res=pst.executeUpdate(); System.out.println("插入结果是:"+res); pst.close(); conn.close(); session.setAttribute("usr", str); response.sendRedirect("regok.jsp"); }else{ session.setAttribute("errmsg", "密码和确认密码不一致"); } }else{ session.setAttribute("errmsg2", "用户名已存在,请重新输入"); } } String err = (String)session.getAttribute("errmsg"); if(err==null){ err=""; } String err2 = (String)session.getAttribute("errmsg2"); if(err2==null){ err2=""; } %> <%=session.getAttribute("errmsg") %> <%=session.getAttribute("errmsg2") %> <form action="" > <p>用户名:<input type="text" value="" name="name"></p> <p>密码:<input type="password" value="" name="password"></p> <p>确认密码:<input type="password" value="" name="password2"></p> <p>邮箱:<input type="text" value="" name="mail"></p> <input type="submit" value="注册"> <input type="reset" value="重置"> </form> </center> </body> </html>
大学四年自学走来,这些私藏的实用工具/学习网站我贡献出来了
大学四年,看课本是不可能一直看课本的了,对于学习,特别是自学,善于搜索网上的一些资源来辅助,还是非常有必要的,下面我就把这几年私藏的各种资源,网站贡献出来给你们。主要有:电子书搜索、实用工具、在线视频学习网站、非视频学习网站、软件下载、面试/求职必备网站。 注意:文中提到的所有资源,文末我都给你整理好了,你们只管拿去,如果觉得不错,转发、分享就是最大的支持了。 一、电子书搜索 对于大部分程序员...
JSON解析——net.sf.json.JSONObject
简介 在程序开发过程中,在参数传递,函数返回值等方面,越来越多的使用JSON。JSON(JavaScript Object Notation)是一种轻量级的数据交换格式,同时也易于机器解析和生成、易于理解、阅读和撰写,而且Json采用完全独立于语言的文本格式,这使得Json成为理想的数据交换语言。 JSON建构于两种结构: “名称/值”对的集合(A Collection of name/va...
卸载 x 雷某度!GitHub 标星 1.5w+,从此我只用这款全能高速下载工具!
作者 | Rocky0429 来源 | Python空间 大家好,我是 Rocky0429,一个喜欢在网上收集各种资源的蒟蒻… 网上资源眼花缭乱,下载的方式也同样千奇百怪,比如 BT 下载,磁力链接,网盘资源等等等等,下个资源可真不容易,不一样的方式要用不同的下载软件,因此某比较有名的 x 雷和某度网盘成了我经常使用的工具。 作为一个没有钱的穷鬼,某度网盘几十 kb 的下载速度让我...
2019年还剩1天,我从外包公司离职了
这日子过的可真快啊,2019年还剩1天,外包公司干了不到3个月,我离职了
我一个37岁的程序员朋友
周末了,人一旦没有点事情干,心里就瞎想,而且跟几个老男人坐在一起,更容易瞎想,我自己现在也是 30 岁了,也是无时无刻在担心自己的职业生涯,担心丢掉工作没有收入,担心身体机能下降,担心突...
计算机网络的核心概念
这是《计算机网络》系列文章的第二篇文章 我们第一篇文章讲述了计算机网络的基本概念,互联网的基本名词,什么是协议以及几种接入网以及网络传输的物理媒体,那么本篇文章我们来探讨一下网络核心、交换网络、时延、丢包、吞吐量以及计算机网络的协议层次和网络攻击。 网络核心 网络的核心是由因特网端系统和链路构成的网状网络,下面这幅图正确的表达了这一点 那么在不同的 ISP 和本地以及家庭网络是如何交换信息的呢?...
python自动下载图片
近日闲来无事,总有一种无形的力量萦绕在朕身边,让朕精神涣散,昏昏欲睡。 可是,像朕这么有职业操守的社畜怎么能在上班期间睡瞌睡呢,我不禁陷入了沉思。。。。 突然旁边的IOS同事问:‘嘿,兄弟,我发现一个网站的图片很有意思啊,能不能帮我保存下来提升我的开发灵感?’ 作为一个坚强的社畜怎么能说自己不行呢,当时朕就不假思索的答应:‘oh, It’s simple. Wait for me for a ...
一名大专同学的四个问题
【前言】   收到一封来信,赶上各种事情拖了几日,利用今天要放下工作的时机,做个回复。   2020年到了,就以这一封信,作为开年标志吧。 【正文】   您好,我是一名现在有很多困惑的大二学生。有一些问题想要向您请教。   先说一下我的基本情况,高考失利,不想复读,来到广州一所大专读计算机应用技术专业。学校是偏艺术类的,计算机专业没有实验室更不用说工作室了。而且学校的学风也不好。但我很想在计算机领...
复习一周,京东+百度一面,不小心都拿了Offer
京东和百度一面都问了啥,面试官百般刁难,可惜我全会。
Java 14 都快来了,为什么还有这么多人固守Java 8?
从Java 9开始,Java版本的发布就让人眼花缭乱了。每隔6个月,都会冒出一个新版本出来,Java 10 , Java 11, Java 12, Java 13, 到2020年3月份,...
达摩院十大科技趋势发布:2020 非同小可!
【CSDN编者按】1月2日,阿里巴巴发布《达摩院2020十大科技趋势》,十大科技趋势分别是:人工智能从感知智能向认知智能演进;计算存储一体化突破AI算力瓶颈;工业互联网的超融合;机器间大规模协作成为可能;模块化降低芯片设计门槛;规模化生产级区块链应用将走入大众;量子计算进入攻坚期;新材料推动半导体器件革新;保护数据隐私的AI技术将加速落地;云成为IT技术创新的中心 。 新的画卷,正在徐徐展开。...
轻松搭建基于 SpringBoot + Vue 的 Web 商城应用
首先介绍下在本文出现的几个比较重要的概念: 函数计算(Function Compute): 函数计算是一个事件驱动的服务,通过函数计算,用户无需管理服务器等运行情况,只需编写代码并上传。函数计算准备计算资源,并以弹性伸缩的方式运行用户代码,而用户只需根据实际代码运行所消耗的资源进行付费。Fun: Fun 是一个用于支持 Serverless 应用部署的工具,能帮助您便捷地管理函数计算、API ...
讲真,这两个IDE插件,可以让你写出质量杠杠的代码
周末躺在床上看《拯救大兵瑞恩》 周末在闲逛的时候,发现了两个优秀的 IDE 插件,据说可以提高代码的质量,我就安装了一下,试了试以后发现,确实很不错,就推荐给大家。 01、Alibaba Java 代码规范插件 《阿里巴巴 Java 开发手册》,相信大家都不会感到陌生,其 IDEA 插件的下载次数据说达到了 80 万次,我今天又贡献了一次。嘿嘿。 该项目的插件地址: https://github....
Python+OpenCV实时图像处理
目录 1、导入库文件 2、设计GUI 3、调用摄像头 4、实时图像处理 4.1、阈值二值化 4.2、边缘检测 4.3、轮廓检测 4.4、高斯滤波 4.5、色彩转换 4.6、调节对比度 5、退出系统 初学OpenCV图像处理的小伙伴肯定对什么高斯函数、滤波处理、阈值二值化等特性非常头疼,这里给各位分享一个小项目,可通过摄像头实时动态查看各类图像处理的特点,也可对各位调参、测试...
2020年一线城市程序员工资大调查
人才需求 一线城市共发布岗位38115个,招聘120827人。 其中 beijing 22805 guangzhou 25081 shanghai 39614 shenzhen 33327 工资分布 2020年中国一线城市程序员的平均工资为16285元,工资中位数为14583元,其中95%的人的工资位于5000到20000元之间。 和往年数据比较: yea...
为什么猝死的都是程序员,基本上不见产品经理猝死呢?
相信大家时不时听到程序员猝死的消息,但是基本上听不到产品经理猝死的消息,这是为什么呢? 我们先百度搜一下:程序员猝死,出现将近700多万条搜索结果: 搜索一下:产品经理猝死,只有400万条的搜索结果,从搜索结果数量上来看,程序员猝死的搜索结果就比产品经理猝死的搜索结果高了一倍,而且从下图可以看到,首页里面的五条搜索结果,其实只有两条才是符合条件。 所以程序员猝死的概率真的比产品经理大,并不是错...
害怕面试被问HashMap?这一篇就搞定了!
声明:本文以jdk1.8为主! 搞定HashMap 作为一个Java从业者,面试的时候肯定会被问到过HashMap,因为对于HashMap来说,可以说是Java集合中的精髓了,如果你觉得自己对它掌握的还不够好,我想今天这篇文章会非常适合你,至少,看了今天这篇文章,以后不怕面试被问HashMap了 其实在我学习HashMap的过程中,我个人觉得HashMap还是挺复杂的,如果真的想把它搞得明明白...
毕业5年,我问遍了身边的大佬,总结了他们的学习方法
我问了身边10个大佬,总结了他们的学习方法,原来成功都是有迹可循的。
程序员如何通过造轮子走向人生巅峰?
前言:你所做的事情,也许暂时看不到成果。但不要灰心,你不是没有成长,而是在扎根。 程序员圈经常流行的一句话:“不要重复造轮子”。在计算机领域,我们将封装好的组件、库,叫做轮子。因为它可以拿来直接用,直接塞进我们的项目中,就能实现对应的功能。 有些同学会问,人家都已经做好了,你再来重新弄一遍,有什么意义?这不是在浪费时间吗。 殊不知,造轮子是一种学习方式,能快速进步,造得好,是自己超强能力的表...
推荐10个堪称神器的学习网站
每天都会收到很多读者的私信,问我:“二哥,有什么推荐的学习网站吗?最近很浮躁,手头的一些网站都看烦了,想看看二哥这里有什么新鲜货。” 今天一早做了个恶梦,梦到被老板辞退了。虽然说在我们公司,只有我辞退老板的份,没有老板辞退我这一说,但是还是被吓得 4 点多都起来了。(主要是因为我掌握着公司所有的核心源码,哈哈哈) 既然 4 点多起来,就得好好利用起来。于是我就挑选了 10 个堪称神器的学习网站,推...
这些软件太强了,Windows必装!尤其程序员!
Windows可谓是大多数人的生产力工具,集娱乐办公于一体,虽然在程序员这个群体中都说苹果是信仰,但是大部分不都是从Windows过来的,而且现在依然有很多的程序员用Windows。 所以,今天我就把我私藏的Windows必装的软件分享给大家,如果有一个你没有用过甚至没有听过,那你就赚了????,这可都是提升你幸福感的高效率生产力工具哦! 走起!???? NO、1 ScreenToGif 屏幕,摄像头和白板...
阿里面试一个ArrayList我都能跟面试官扯半小时
我是真的没想到,面试官会这样问我ArrayList。
曾经优秀的人,怎么就突然不优秀了。
职场上有很多辛酸事,很多合伙人出局的故事,很多技术骨干被裁员的故事。说来模板都类似,曾经是名校毕业,曾经是优秀员工,曾经被领导表扬,曾经业绩突出,然而突然有一天,因为种种原因,被裁员了,...
大学四年因为知道了这32个网站,我成了别人眼中的大神!
依稀记得,毕业那天,我们导员发给我毕业证的时候对我说“你可是咱们系的风云人物啊”,哎呀,别提当时多开心啦????,嗯,我们导员是所有导员中最帅的一个,真的???? 不过,导员说的是实话,很多人都叫我大神的,为啥,因为我知道这32个网站啊,你说强不强????,这次是绝对的干货,看好啦,走起来! PS:每个网站都是学计算机混互联网必须知道的,真的牛杯,我就不过多介绍了,大家自行探索,觉得没用的,尽管留言吐槽吧???? 社...
良心推荐,我珍藏的一些Chrome插件
上次搬家的时候,发了一个朋友圈,附带的照片中不小心暴露了自己的 Chrome 浏览器插件之多,于是就有小伙伴评论说分享一下我觉得还不错的浏览器插件。 我下面就把我日常工作和学习中经常用到的一些 Chrome 浏览器插件分享给大家,随便一个都能提高你的“生活品质”和工作效率。 Markdown Here Markdown Here 可以让你更愉快的写邮件,由于支持 Markdown 直接转电子邮...
看完这篇HTTP,跟面试官扯皮就没问题了
我是一名程序员,我的主要编程语言是 Java,我更是一名 Web 开发人员,所以我必须要了解 HTTP,所以本篇文章就来带你从 HTTP 入门到进阶,看完让你有一种恍然大悟、醍醐灌顶的感觉。 最初在有网络之前,我们的电脑都是单机的,单机系统是孤立的,我还记得 05 年前那会儿家里有个电脑,想打电脑游戏还得两个人在一个电脑上玩儿,及其不方便。我就想为什么家里人不让上网,我的同学 xxx 家里有网,每...
史上最全的IDEA快捷键总结
现在Idea成了主流开发工具,这篇博客对其使用的快捷键做了总结,希望对大家的开发工作有所帮助。
阿里程序员写了一个新手都写不出的低级bug,被骂惨了。
这种新手都不会范的错,居然被一个工作好几年的小伙子写出来,差点被当场开除了。
谁是华为扫地僧?
是的,华为也有扫地僧!2020年2月11-12日,“养在深闺人不知”的华为2012实验室扫地僧们,将在华为开发者大会2020(Cloud)上,和大家见面。到时,你可以和扫地僧们,吃一个洋...
Idea 中最常用的10款插件(提高开发效率),一定要学会使用!
学习使用一些插件,可以提高开发效率。对于我们开发人员很有帮助。这篇博客介绍了开发中使用的插件。
AI 没让人类失业,搞 AI 的人先失业了
最近和几个 AI 领域的大佬闲聊 根据他们讲的消息和段子 改编出下面这个故事 如有雷同 都是巧合 1. 老王创业失败,被限制高消费 “这里写我跑路的消息实在太夸张了。” 王葱葱哼笑一下,把消息分享给群里。 阿杰也看了消息,笑了笑。在座几位也都笑了。 王葱葱是个有名的人物,21岁那年以全额奖学金进入 KMU 攻读人工智能博士,累计发表论文 40 余篇,个人技术博客更是成为深度学习领域内风向标。 ...
立即提问