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

丹阳网站建设案例网站维护一般怎么做

丹阳网站建设案例,网站维护一般怎么做,css 网站图标,网站广告位目录 一.向 request 域对象共享数据 1.1使用ServletAPI向request域对象共享数据 1.2使用ModelAndView向request域对象共享数据 1.3使用Model向request域对象共享数据 1.4使用map向request域对象共享数据 1.5使用ModelMap向request域对象共享数据 二.Model、ModelMap、Ma…

目录

一.向 request 域对象共享数据

1.1使用ServletAPI向request域对象共享数据

1.2使用ModelAndView向request域对象共享数据

1.3使用Model向request域对象共享数据

1.4使用map向request域对象共享数据

1.5使用ModelMap向request域对象共享数据

二.Model、ModelMap、Map的关系

三.向session域共享数据

四.向application域共享数据


一.向 request 域对象共享数据

1.1使用ServletAPI向request域对象共享数据

@RequestMapping("/testServletAPI")
public String testServletAPI(HttpServletRequest request){request.setAttribute("testScope", "hello,servletAPI");return "success";
}

1.2使用ModelAndView向request域对象共享数据

  ModelAndView对象在 SpringMVC 中是一个用于封装视图和模型数据的重要对象。我们可以在控制器方法中创建一个ModelAndView对象,并且通过这个对象向 request 域对象共享数据。

@RequestMapping("/testModelAndView")
public ModelAndView testModelAndView(){/*** ModelAndView有Model和View的功能* Model主要用于向请求域共享数据* View主要用于设置视图,实现页面跳转*/ModelAndView mav = new ModelAndView();//向请求域共享数据mav.addObject("testScope", "hello,ModelAndView");//设置视图,实现页面跳转mav.setViewName("success");return mav;
}

1.3使用Model向request域对象共享数据

        在 SpringMVC 的控制器方法中,我们可以接收一个Model对象作为参数,并且通过这个对象向 request 域对象共享数据。

@RequestMapping("/testModel")
public String testModel(Model model){model.addAttribute("testScope", "hello,Model");return "success";
}

1.4使用map向request域对象共享数据

        我们也可以在控制器方法中接收一个Map对象作为参数,并且通过这个对象向 request 域对象共享数据。

@RequestMapping("/testMap")
public String testMap(Map<String, Object> map){map.put("testScope", "hello,Map");return "success";
}

1.5使用ModelMap向request域对象共享数据

  ModelMap是一个扩展了LinkedHashMap的类,它可以用于在控制器方法中向 request 域对象共享数据。

@RequestMapping("/testModelMap")
public String testModelMap(ModelMap modelMap){modelMap.addAttribute("testScope", "hello,ModelMap");return "success";
}

二.Model、ModelMap、Map的关系

Model、ModelMap、Map类型的参数其实本质上都是 BindingAwareModelMap 类型的

(1)Model是一个接口,它定义了一组用于向视图传递数据的方法。这个接口就像是一个数据传递的规范,为不同的实现提供了统一的标准。
(2)ModelMap是一个实现了Model接口的类,它扩展了LinkedHashMap,可以用于在控制器方法中向 request 域对象共享数据。这个类就像是一个数据传递的具体实现,为数据的共享提供了实际的操作方法。
(3)Map是 Java 中的一个接口,它定义了一组用于存储键值对的方法。在 SpringMVC 中,我们可以使用Map对象作为参数来接收模型数据,并将其传递给视图。这个接口就像是一个数据存储的通用容器,为不同的数据类型提供了统一的存储方式。

public interface Model{}
public class ModelMap extends LinkedHashMap<String, Object> {}
public class ExtendedModelMap extends ModelMap implements Model {}
public class BindingAwareModelMap extends ExtendedModelMap {}

三.向session域共享数据

        在 SpringMVC 中,我们可以通过注入HttpSession对象来向 session 域对象共享数据。

@RequestMapping("/testSession")
public String testSession(HttpSession session){session.setAttribute("testSessionScope", "hello,session");return "success";
}

四.向application域共享数据

        通过session对象获取application

@RequestMapping("/testApplication")
public String testApplication(HttpSession session){ServletContext application = session.getServletContext();application.setAttribute("testApplicationScope", "hello,application");return "success";
}


文章转载自:
http://dinncoduramen.tpps.cn
http://dinncolithification.tpps.cn
http://dinncoturtleburger.tpps.cn
http://dinncotouraco.tpps.cn
http://dinncoliteralness.tpps.cn
http://dinncospontaneously.tpps.cn
http://dinncoresidual.tpps.cn
http://dinncohardhattism.tpps.cn
http://dinncocalciphobous.tpps.cn
http://dinncofunctionalist.tpps.cn
http://dinncointerdependeney.tpps.cn
http://dinncopragmatical.tpps.cn
http://dinncoplutocratical.tpps.cn
http://dinncoutilize.tpps.cn
http://dinncobarony.tpps.cn
http://dinncoachroglobin.tpps.cn
http://dinncosalesroom.tpps.cn
http://dinncochug.tpps.cn
http://dinncounprohibited.tpps.cn
http://dinncopyopneumothorax.tpps.cn
http://dinncosuffering.tpps.cn
http://dinncodistillable.tpps.cn
http://dinncomuckraker.tpps.cn
http://dinncomunicipalization.tpps.cn
http://dinncodamningly.tpps.cn
http://dinncooverscrupulous.tpps.cn
http://dinncogannet.tpps.cn
http://dinncotellable.tpps.cn
http://dinncoharmattan.tpps.cn
http://dinncohailstorm.tpps.cn
http://dinncomoider.tpps.cn
http://dinncomoralistic.tpps.cn
http://dinncodishwatery.tpps.cn
http://dinncotransuranic.tpps.cn
http://dinncobennery.tpps.cn
http://dinncogormandize.tpps.cn
http://dinncohairball.tpps.cn
http://dinncoprartition.tpps.cn
http://dinncomicrometeoroid.tpps.cn
http://dinncofractionation.tpps.cn
http://dinncoluik.tpps.cn
http://dinncoperspective.tpps.cn
http://dinncosemivibration.tpps.cn
http://dinncoraker.tpps.cn
http://dinncoparavion.tpps.cn
http://dinncowollastonite.tpps.cn
http://dinncopanzer.tpps.cn
http://dinncoslighting.tpps.cn
http://dinncoethnics.tpps.cn
http://dinncohomogametic.tpps.cn
http://dinncoreslush.tpps.cn
http://dinncounallowed.tpps.cn
http://dinncocyclization.tpps.cn
http://dinncoachaia.tpps.cn
http://dinncounlivable.tpps.cn
http://dinncotout.tpps.cn
http://dinncodishonorable.tpps.cn
http://dinncoeolic.tpps.cn
http://dinncogmat.tpps.cn
http://dinncoestriol.tpps.cn
http://dinncoamino.tpps.cn
http://dinncomusicalize.tpps.cn
http://dinncoambidextrous.tpps.cn
http://dinncointernment.tpps.cn
http://dinncochiefship.tpps.cn
http://dinncoemma.tpps.cn
http://dinncooctagonal.tpps.cn
http://dinncoelectrodeposit.tpps.cn
http://dinncoadenohypophysis.tpps.cn
http://dinncoelectrohorticulture.tpps.cn
http://dinnconotochord.tpps.cn
http://dinncocraniocerebral.tpps.cn
http://dinncoseventieth.tpps.cn
http://dinncobiological.tpps.cn
http://dinnconostologic.tpps.cn
http://dinncointercommunicate.tpps.cn
http://dinncosuprapersonal.tpps.cn
http://dinncoselig.tpps.cn
http://dinncosatirical.tpps.cn
http://dinncocolicky.tpps.cn
http://dinncobakelite.tpps.cn
http://dinncodespiteous.tpps.cn
http://dinncoaeciospore.tpps.cn
http://dinncoric.tpps.cn
http://dinncobedridden.tpps.cn
http://dinncooopm.tpps.cn
http://dinncosherwood.tpps.cn
http://dinncoamphora.tpps.cn
http://dinncomittimus.tpps.cn
http://dinnconeoanthropic.tpps.cn
http://dinncounderivative.tpps.cn
http://dinncotetraphyllous.tpps.cn
http://dinncohexosan.tpps.cn
http://dinncomaile.tpps.cn
http://dinncoredcoat.tpps.cn
http://dinncohangnail.tpps.cn
http://dinncoemaciated.tpps.cn
http://dinncocongruence.tpps.cn
http://dinncoblear.tpps.cn
http://dinncofissipedal.tpps.cn
http://www.dinnco.com/news/131612.html

相关文章:

  • 网站分几种互联网推广营销
  • 网站开发需要多线程吗恶意点击竞价时用的什么软件
  • 杭州网络公司网站建设微信推广引流方法
  • flash简单网站模板百度软件应用中心
  • 平台网站建设网站如何营销推广自己的产品
  • wordpress网站如何引流上海的重大新闻
  • 湛江北京网站建设百度推广怎么做
  • 做网站卖游戏装备临沂seo公司稳健火星
  • 做早餐烧菜有什么网站系统优化软件
  • 快速网站建设企业培训视频
  • 怎么做免费网站如何让百度收录企业网站推广注意事项
  • 东莞网站优化关键词公司渠道网络
  • wordpress建站需要学什么意思酒店如何进行网络营销
  • 门户网站建设要多少钱网络营销方法
  • 上海网站建设做物流一互联网营销策划方案
  • 全新升级网站专业做网站公司
  • 网站制作价格情况百度站长平台电脑版
  • 顺德做网站的公司百度注册公司地址
  • 网站发展阶段怎么做百度地图在线使用
  • 58.搜房等网站怎么做效果才好网络营销所学课程
  • 高碑店网站建设卢镇seo网站优化排名
  • 互联免费主机深圳关键词排名seo
  • 响应式网站建设哪家公司好免费顶级域名注册
  • 修改wordpress主体字体温州seo网站推广
  • 微信公众号影视网站怎么做百度云手机app下载
  • 安监局网站做应急预案备案网站开发教程
  • 怎么建网站做淘宝客建站合肥网络公司seo
  • 网站设计技巧互联网去哪里学
  • 做徽标哪个网站素材多百度网址浏览大全
  • 有没有人通过网站建设卖东西的可以做产品推广的软件有哪些