91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

android webview can't get vertx session

發布時間:2020-08-06 15:14:24 來源:網絡 閱讀:633 作者:北京看看 欄目:開發技術

android webview can't get session when using target="_blank" with <a> link.

### Version 3.5.1 (maybe 3.5.0 included,not sure)


* vert.x core:

* vert.x web:


### Context


I used android webview to call a vertx url,when I switched from one page to another, the vertx server would always generate a new session id, so I lost session data set by previous page.

But,when I use iphone webview or PC Chrome to call the same vertx server, the session can be remembered correctly.  so the error is only subject to android webview 


### Do you have a reproducer?

we can reproducer the error following the steps below.


### Steps to reproduce


1. write a smiple verticle

public class Test1Verticle  extends AbstractVerticle {
	 Router router1 ; 
	  @Override
	  public void start() throws Exception {
	    router1 = Router.router(vertx);	 	    
	    router1.route().handler(CookieHandler.create());
	    router1.route().handler(SessionHandler.create(LocalSessionStore.create(vertx)));
	    router1.route("/h6/*").handler(StaticHandler.create("web/h6"));
	    router1.route("/hit").handler(this::hit);	
	    vertx.createHttpServer().requestHandler(router1::accept).listen(8080) ;    
	  }	  
	  private void hit(RoutingContext routingContext) {
		  Session session = routingContext.session();
	      Integer cnt = session.get("hitcount");
	      cnt = (cnt == null ? 0 : cnt) + 1;
	      session.put("hitcount", cnt);
		  routingContext.response().putHeader("content-type", "application/json;charset=UTF-8")
         .end(new JsonObject().put("data", "cnt="+cnt) );
	   } 
	  
	}

2.  place 2 html files in the web/h6 file folder,named test3.html and test4.html respectively. test3.html source code:

<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
	<title>test3.html</title>
	<script type="text/javascript" src="//cdn.bootcss.com/jquery/2.0.3/jquery.min.js"></script>
</head>
<body>
<div id="myData"></div>
<div id="myData2"><a href="test4.html" target="_blank">call test4</a></div>
<script type="text/javascript" charset="utf-8">
	$.ajax({ url:"/hit?time="+(new Date().getTime()), 
									type:"post", 
									dataType : "json",
									success: function(resp){
										console.log(resp)
										$("#myData").html(resp.data);
									},
									error: function(){
										$j("#myData").html("error.");
										me.resetload();
									}
								});	
</script>
</body>
</html>

the source code of test4.html is similar to the above,just replace the href to test3.html

3. ...

start the vertx verticle, and open an android browser,input the url (http://192.168.0.13:8080/h6/test3.html) in the browser,then submit

4.  you can find ,after jump to the other html,the hit count remains to 1, but if you call the url in iphone or PC browser, the hit count will be found to increment correctly.

5,if we remove the target="_blank" in the html file, the session will work properly


2018-04-21 13:42 update:

I tested on several android phone ,and foud that the session problem did not appear on all android phone, Mi and Huawei could reproduce this error,but sumsung and Lenovo worked correctly.

at last,I added some code in my verticle file to address this problem:

//to make session work correctly on Huawei phone, set Cookie Path to root '/' 
        Set<Cookie> ccList=routingContext.cookies();
        for(Cookie ck:ccList){
        	ck.setPath("/");        	
        }





向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

海城市| 称多县| 嵩明县| 汶上县| 平果县| 乐安县| 荔波县| 石狮市| 册亨县| 嘉定区| 邛崃市| 军事| 聊城市| 天峻县| 铅山县| 广元市| 临城县| 太湖县| 南城县| 安溪县| 灵宝市| 莱西市| 茂名市| 清远市| 云梦县| 启东市| 辉南县| 竹北市| 武胜县| 松江区| 石林| 延长县| 平塘县| 泌阳县| 鄂尔多斯市| 华亭县| 武汉市| 屏边| 宁安市| 阿勒泰市| 高青县|