URL中“#” “?” &“”号的作用

1. #

    10年9月,twitter改版。一个显著变化,就是URL加入了"#!"符号。比如,改版前的用户主页网址为http://twitter.com/username改版后,就变成了http://twitter.com/#!/username
  这是主流网站第一次将"#"大规模用于重要URL中。这表明井号(Hash)的作用正在被重新认识。本文根据HttpWatch的文章,整理与井号有关的所有重要知识点。
一、#的涵义
  #代表网页中的一个位置。其右面的字符,就是该位置的标识符。比如,http://www.example.com/index.html#print就代表网页index.html的print位置。浏览器读取这个URL后,会自动将print位置滚动至可视区域。
  为网页位置指定标识符,有两个方法。一是使用锚点,比如<a name="print"></a>,二是使用id属性,比如<div id="print">。


二、HTTP请求不包括#
  #是用来指导浏览器动作的,对服务器端完全无用。所以,HTTP请求中不包括#。
比如,访问下面的网址,http://www.example.com/index.html#print,浏览器实际发出的请求是这样的:

GET /index.html HTTP/1.1
Host: www.example.com

 

三、#后的字符
  在第一个#后面出现的任何字符,都会被浏览器解读为位置标识符。这意味着,这些字符都不会被发送到服务器端。
比如,下面URL的原意是指定一个颜色值:http://www.example.com/?color=#fff,但是,浏览器实际发出的请求是:

GET /?color= HTTP/1.1
Host: www.example.com

   

四、改变#不触发网页重载
  单单改变#后的部分,浏览器只会滚动到相应位置,不会重新加载网页。
比如,从http://www.example.com/index.html#location1改成http://www.example.com/index.html#location2,浏览器不会重新向服务器请求index.html。

 

五、改变#会改变浏览器的访问历史
  每一次改变#后的部分,都会在浏览器的访问历史中增加一个记录,使用"后退"按钮,就可以回到上一个位置。这对于ajax应用程序特别有用,可以用不同的#值,表示不同的访问状态,然后向用户给出可以访问某个状态的链接。值得注意的是,上述规则对IE 6和IE 7不成立,它们不会因为#的改变而增加历史记录。
  

六、window.location.hash读取#值
  window.location.hash这个属性可读可写。读取时,可以用来判断网页状态是否改变;写入时,则会在不重载网页的前提下,创造一条访问历史记录。
  

七、onhashchange事件
  这是一个HTML 5新增的事件,当#值发生变化时,就会触发这个事件。IE8+、Firefox 3.6+、Chrome 5+、Safari 4.0+支持该事件。
  它的使用方法有三种:

  • window.onhashchange = func;
  • <body onhashchange="func();">
  • window.addEventListener("hashchange", func, false);

  对于不支持onhashchange的浏览器,可以用setInterval监控location.hash的变化。

八、Google抓取#的机制
  默认情况下,Google的网络蜘蛛忽视URL的#部分。
  但是,Google还规定,如果你希望Ajax生成的内容被浏览引擎读取,那么URL中可以使用"#!",Google会自动将其后面的内容转成查询字符串_escaped_fragment_的值。
  比如,Google发现新版twitter的URL:http://twitter.com/#!/username
  就会自动抓取另一个URL:http://twitter.com/?_escaped_fragment_=/username
  通过这种机制,Google就可以索引动态的Ajax内容。

 

AJAX = 异步 JavaScriptXML标准通用标记语言的子集)。AJAX 是一种用于创建快速动态网页的技术。

2. ?

1)连接作用:比如

http://www.xxx.com/Show.asp?id=77&nameid=2905210001&page=1

2)清除缓存:比如

http://www.xxxxx.com/index.html 
http://www.xxxxx.com/index.html?test123123

两个url打开的页面一样,但是后面这个有问号,说明不调用缓存的内容,而认为是一个新地址,重新读取。

3. &

不同参数的间隔符

# ???? WEB ???? server.port=7090 server.servlet.context-path=/api #session???? 60M ???? server.servlet.session.timeout=PT60M #??favicon spring.mvc.favicon.enable=false #???? spring.mvc.throw-exception-if-no-handler-found=true spring.web.resources.add-mappings=false spring.servlet.multipart.max-file-size=20MB spring.servlet.multipart.max-request-size=20MB #数据库设置 spring.datasource.url=jdbc:mysql://118.24.147.138:3306/wangpan?serverTimezone=GMT%2B8&amp;useUnicode=true&amp;characterEncoding=utf8&amp;autoReconnect=true&amp;allowMultiQueries=true spring.datasource.username=wangpan spring.datasource.password=rootroot spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver spring.datasource.hikari.pool-name=HikariCPDatasource spring.datasource.hikari.minimum-idle=5 spring.datasource.hikari.idle-timeout=180000 spring.datasource.hikari.maximum-pool-size=10 spring.datasource.hikari.auto-commit=true spring.datasource.hikari.max-lifetime=1800000 spring.datasource.hikari.connection-timeout=30000 spring.datasource.hikari.connection-test-query=SELECT 1 #???????? # ?????????? smtp.qq.com spring.mail.host=smtp.qq.com # ??????? spring.mail.port=465 # ??? spring.mail.username=3824245251@qq.com # spring.mail.password=ehcyxusufuulccah # ???? spring.mail.default-encoding=UTF-8 # SSL???? spring.mail.properties.mail.smtp.socketFactory.class=javax.net.ssl.SSLSocketFactory # ?? debug???????????????? spring.mail.properties.mail.debug=true #?????? #Spring redis?? # Redis?????????0? spring.redis.database=0 spring.redis.host=118.24.147.138 spring.redis.port=6379 # ???????????????????? spring.redis.jedis.pool.max-active=20 # ??????????????????????? spring.redis.jedis.pool.max-wait=-1 # ??????????? spring.redis.jedis.pool.max-idle=10 # ??????????? spring.redis.jedis.pool.min-idle=0 # ?????????? spring.redis.timeout=2000 #项目目录 project.folder=/www/wangpan/ # log.root.level=debug #内部端口 inner.api.appKey=wangpan inner.api.appSecret=wangpan_key #web端口 web.api.url=http://118.24.147.138:7090 #管理员id admin.emails=961285867@qq.com #是否是开发环境 dev=false ##qq????## qq.app.id=12333 qq.app.key=2222222 qq.url.authorization=https://graph.qq.com/oauth2.0/authorize?response_type=code&amp;client_id=%s&amp;redirect_uri=%s&amp;state=%s qq.url.access.token=https://graph.qq.com/oauth2.0/token?grant_type=authorization_code&amp;client_id=%s&amp;client_secret=%s&amp;code=%s&amp;redirect_uri=%s qq.url.openid=https://graph.qq.com/oauth2.0/me?access_token=%S qq.url.user.info=https://graph.qq.com/user/get_user_info?access_token=%s&amp;oauth_consumer_key=%s&amp;openid=%s qq.url.redirect=http://wangpan.wuhancoder.com/qqlogincalback springboot的配置文件,部署到服务器上,有什么错误吗
最新发布
05-13
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值