昨天遇到一個問題:經過get請求,將「http://127.0.0.1:8080/ServletWebTest/test/test1.jsp?id=1111111111111111111」 id的值直接經過<%=id%>的方式彈出。javascript
頁面顯示id=1111111111111111111,但alert中顯示「1111111111111112000」?css
第一:其js將id數據轉換位number類型,16位之後的數據變爲0html
(具體的緣由沒找到,可是根據科學計數法,只顯示小數點後16位,如"2.76325901626201e+21")java
網上找到一個帖子,能夠大概的看到緣由,以下:segmentfault
地址:https://segmentfault.com/q/1010000006692622jsp
如下是測試代碼:測試
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; //測試 String id = request.getParameter("id"); System.out.println("id="+id); %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <base href="<%=basePath%>"> <title>測試</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <!-- <link rel="stylesheet" type="text/css" href="styles.css"> --> </head> <body> 測試案例:url=127.0.0.1:8080/ServletWebTest/test1.jsp?id=1111111111111111111 使用《%=%》方式顯示值<br> <hr/> id = <%=id %> label-id=<label id="label"><%=id %></label> <script type="text/javascript"> var i = 1111111111111111111;//19位 window.onload=function(){ alert("id="+<%=id %>); alert("i = "+ i); var a = parseInt(276325901626200949000); var b = parseInt(0.27632590162620094e+22); console.log(a,b); } </script> </body> </html>