当前位置: 首页 > news >正文

网站服务器 优帮云北京网站建设设计

网站服务器 优帮云,北京网站建设设计,可以做动漫网站的源码源码,装修公司哪家口碑好问题 工作中场景需要通过获取url地址内容#xff0c;展示返回给客户端#xff0c;但上线后发现不满足需求#xff0c;原因是url地址进行302重定向#xff0c; 进一步了解是因为HttpUtil.get方法不能获取重定向地址#xff0c;需要使用HttpUtil.createGet()来设置打开重定展示返回给客户端但上线后发现不满足需求原因是url地址进行302重定向 进一步了解是因为HttpUtil.get方法不能获取重定向地址需要使用HttpUtil.createGet()来设置打开重定 理解302 302 表示临时性重定向访问一个Url时被重定向到另一个url上常用于页面跳转。 302与301的区别 301是指永久性的移动302是暂时性的即以后还可能有变化 其它重定向方式 在响应头中加入Location参数。浏览器接受到带有location头的响应时就会跳转到相应的地址。 Spring实现302的几种方式 1、使用RedirectView实现重定向 GetMapping(/redirect/v1)public RedirectView redirectV1() {//创建RedirectView对象并设置目标URLRedirectView view new RedirectView();//view.setUrl(https://www.baidu.com);view.setUrl(/springboot/redirect/index);Properties properties new Properties();properties.setProperty(name, make);view.setAttributes(properties);return view;}2、HttpServletResponse重定向 通过HttpServletResponse往输出流中写数据的方式来返回结果, 实现重定向 ResponseBodyGetMapping(/redirect/v2)public void redirectV2(HttpServletResponse response) throws IOException {response.sendRedirect(https://www.sina.com.cn);}3、通过redirect关键词 常适用于返回视图的接口在返回的字符串前面添加redirect:方式来告诉Spring框架需要做302重定向处理; ResponseBodyGetMapping(/redirect/v3)public String redirectV3() throws IOException {return redirect:/redirect/index?baser1;}完整测试 import com.alibaba.fastjson.JSON; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.servlet.view.RedirectView;import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.sql.DataSource; import java.io.IOException; import java.util.Properties;Controller public class RedirectController {/*** 使用RedirectView实现重定向*/GetMapping(/redirect/v1)public RedirectView redirectV1() {//创建RedirectView对象并设置目标URLRedirectView view new RedirectView();//view.setUrl(https://www.baidu.com);view.setUrl(/springboot/redirect/index);Properties properties new Properties();properties.setProperty(name, make);view.setAttributes(properties);return view;}/*** HttpServletResponse重定向* 通过HttpServletResponse往输出流中写数据的方式来返回结果, 实现重定向*/ResponseBodyGetMapping(/redirect/v2)public void redirectV2(HttpServletResponse response) throws IOException {response.sendRedirect(https://www.sina.com.cn);}/*** 返回redirect* 常适用于返回视图的接口在返回的字符串前面添加redirect:方式来告诉Spring框架需要做302重定向处理;*/ResponseBodyGetMapping(/redirect/v3)public String redirectV3() throws IOException {return redirect:/redirect/index?baser1;}ResponseBodyGetMapping(path /redirect/index)public String index(HttpServletRequest request) {return 重定向访问! JSON.toJSONString(request.getParameterMap());} }
http://www.pierceye.com/news/628620/

相关文章:

  • 仿《爱美眉》网站 dede门户网站的主要功能
  • 外发加工网站深圳如何优化
  • 做设计在哪个网站上找高清图片大全网站建设风险分析
  • 做兼职哪个网站好哪些网站做免费送东西的广告6
  • 网站建设战略互动模板wordpress
  • 三原网站建设网易企业邮箱登录v
  • 为网站营销好处wordpress tar.xz
  • wordpress建站比较淘宝客网站怎么建设
  • 网站结构有哪些安徽省建设工程信息网官方网站
  • 如何查看网站是否备案直播网站怎么做啊
  • 广西做网站的公司投资融资理财网站模板
  • 做网站的颜色游戏推广员拉人犯法吗
  • 金融审核网站制作站长之家网址ip查询
  • 石家庄做家教网站网络营销网站建设
  • 怎么做淘宝网站赚钱吗怎样提高百度推广排名
  • 购物网站建设成本u9u8网站建设
  • 抚州市住房和城乡建设局网站手机网站素材
  • 用dw做音乐网站模板策划公司收费明细
  • 大气手机网站模板免费下载南昌seo排名
  • 做卖衣服网站源代码seo搜索引擎优化名词解释
  • 东营免费建网站网络运维必备知识
  • 盐城建设网站备案 网站负责人
  • 外贸营销网站怎么建设网站域名注册证书
  • 安徽网站建设首选-晨飞网络甘肃泾川县门户网站两学一做
  • 360°网站标签旋转显示特效建筑设计专业比较好的学校
  • 郫县建设局网站中文wordpress模版
  • 塔里木油田公司档案馆网站建设研究响应式网站建设教程
  • wordpress侧边栏怎么加php代码重庆seo优化公司
  • 自做建材配送网站做的比较好的游戏网站
  • 建设网站公司兴田德润在哪里秦皇岛海港区