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

网站搭建代码大全淘宝优化关键词的步骤

网站搭建代码大全,淘宝优化关键词的步骤,公司简介模板文案,手机企业网站如何建设记录一些很基本的使用方法。 一、GET请求传参方法: 1.方法一:把参数传到?之后 使用注解RequestParam // 假如传值了current和limit /students?current1&limit20 RequestMapping(value "/students", method RequestMetho…

记录一些很基本的使用方法。

一、GET请求传参方法:

1.方法一:把参数传到?之后 使用注解@RequestParam

// 假如传值了current和limit  /students?current=1&limit=20
@RequestMapping(value = "/students", method = RequestMethod.GET)
@ResponseBody
// name代表传的参数名,require代表不传这个值也行,defaultvalue代表默认值
// 默认current和limit参数是int类型
public String getStudents(@RequestParam(name = "current", required = false, defaultValue = "1") int current,@RequestParam(name = "limit", required = false, defaultValue = "1") int limit) {return "some students:" + current + " " + limit;
}

2.方法二:传到路径当中 使用注解@PathVariable指定

// /student/123      查找一个学生
@RequestMapping(value = "/student/{id}", method = RequestMethod.GET)
@ResponseBody
public String getStudent(@PathVariable("id") int id) {return "a student" + " " + id;
}

二、POST请求传参方法:默认使用表单提交,获取表单中字段的name属性

// 这里表单传入了一个学生的姓名和年龄  
@RequestMapping(value = "/student", method = RequestMethod.POST)
@ResponseBody
public String saveString(String name, int age) {System.out.println("name:" + name);return "success" + " " + name + " " + age;
}

三、响应HTML数据,分别使用ModelAndView  和Model

使用ModelAndView :

// 这里是model和view都封装在一个对象中
// 不加@ResponseBody  返回的就是html;  加了就返回其他对象,比如json
@RequestMapping(value = "/teacher", method = RequestMethod.GET)
public ModelAndView getTeacher(ModelAndView modelAndView) {modelAndView.addObject("name","ym");modelAndView.addObject("age", 21);// 指定一下模板目录  会默认在templates目录下  下面的/view也就是view.htmlmodelAndView.setViewName("/demo/view");return modelAndView;
}

使用Model:

// model与view分开
@RequestMapping(value = "/school", method = RequestMethod.GET)
public String getSchool(Model model) {model.addAttribute("name", "北京大学");model.addAttribute("age", 100);return "/demo/view";
}

四、响应JSON数据,主要针对异步请求(ajax等等)

// Java对象返回给浏览器,解析为JS对象,就用JSON完成前面的操作 java->json->js对象
@RequestMapping(value = "/emp", method = RequestMethod.GET)
@ResponseBody
public Map<String, Object> getEmp() {Map<String, Object> emp = new HashMap<>();emp.put("name", "ljm");emp.put("salary", 18000);emp.put("age", 21);return emp;
}

五、cookie示例

分别编写了设置cookie和获取cookie的方法,

@GetMapping("/cookie/set")
@ResponseBody
// 把cookie放在response响应里
public String setCookie(HttpServletResponse response) {// 创建cookie    这里使用uuid随机创建值Cookie cookie = new Cookie("code", CommunityUtil.generateUUID());// 设置cookie生效的范围  也就是说只在访问下面这个链接时生效cookie.setPath("/community/alpha");// 默认关闭浏览器就失效  但可以设置时间保证cookie的存活时间cookie.setMaxAge(60 * 10);// 发送cookieresponse.addCookie(cookie);return "set cookie";
}@RequestMapping("/cookie/get")
@ResponseBody
// “code”是上面设置的值
public String getCookie(@CookieValue("code") String code) {System.out.println("code:" + code);return "get cookie";
}

 六、session示例

@RequestMapping("/session/set")
@ResponseBody
public String setSession(HttpSession session) {session.setAttribute("id", 1);session.setAttribute("name", "Test");return "set session";
}
@RequestMapping("/session/get")
@ResponseBody
public String getSession(HttpSession session) {System.out.println(session.getAttribute("id"));System.out.println(session.getAttribute("name"));return "get session";
}


文章转载自:
http://bezel.c7501.cn
http://peccancy.c7501.cn
http://yesterday.c7501.cn
http://transonic.c7501.cn
http://outlast.c7501.cn
http://aiblins.c7501.cn
http://cobbly.c7501.cn
http://caprificator.c7501.cn
http://toothlet.c7501.cn
http://crackers.c7501.cn
http://microfilaria.c7501.cn
http://gunfire.c7501.cn
http://technotronic.c7501.cn
http://mormon.c7501.cn
http://frore.c7501.cn
http://perai.c7501.cn
http://limnic.c7501.cn
http://subtransparent.c7501.cn
http://vertigo.c7501.cn
http://hypereutectoid.c7501.cn
http://pushily.c7501.cn
http://doormat.c7501.cn
http://smilingly.c7501.cn
http://bromelia.c7501.cn
http://abecedarium.c7501.cn
http://spectra.c7501.cn
http://quinquecentennial.c7501.cn
http://ariadne.c7501.cn
http://leu.c7501.cn
http://diol.c7501.cn
http://bronchitis.c7501.cn
http://rototill.c7501.cn
http://glomma.c7501.cn
http://auriscopically.c7501.cn
http://snapbolt.c7501.cn
http://remorse.c7501.cn
http://wongai.c7501.cn
http://macrocephalia.c7501.cn
http://ingvaeonic.c7501.cn
http://cassava.c7501.cn
http://crystallize.c7501.cn
http://vysotskite.c7501.cn
http://islomania.c7501.cn
http://hypermedia.c7501.cn
http://piling.c7501.cn
http://benzal.c7501.cn
http://seminatural.c7501.cn
http://holotype.c7501.cn
http://caelian.c7501.cn
http://astrometer.c7501.cn
http://ivorian.c7501.cn
http://insensate.c7501.cn
http://actuation.c7501.cn
http://belvedere.c7501.cn
http://renewedly.c7501.cn
http://underlay.c7501.cn
http://microprojector.c7501.cn
http://inventroy.c7501.cn
http://viviparous.c7501.cn
http://surprisal.c7501.cn
http://inlet.c7501.cn
http://scagliola.c7501.cn
http://indignation.c7501.cn
http://aye.c7501.cn
http://dracaena.c7501.cn
http://megapod.c7501.cn
http://thief.c7501.cn
http://tannin.c7501.cn
http://strewment.c7501.cn
http://navigate.c7501.cn
http://kuban.c7501.cn
http://latices.c7501.cn
http://matriarchate.c7501.cn
http://pupate.c7501.cn
http://ephemeralization.c7501.cn
http://simplex.c7501.cn
http://autoconditioning.c7501.cn
http://kolkhoznik.c7501.cn
http://therezina.c7501.cn
http://akala.c7501.cn
http://tinware.c7501.cn
http://sciagraph.c7501.cn
http://squat.c7501.cn
http://physiognomical.c7501.cn
http://alogical.c7501.cn
http://vlan.c7501.cn
http://muezzin.c7501.cn
http://eschar.c7501.cn
http://felsitic.c7501.cn
http://shower.c7501.cn
http://rsj.c7501.cn
http://unison.c7501.cn
http://unreported.c7501.cn
http://inositol.c7501.cn
http://provokable.c7501.cn
http://pentastyle.c7501.cn
http://karakteristika.c7501.cn
http://nonliving.c7501.cn
http://noia.c7501.cn
http://ineffectually.c7501.cn
http://www.zhongyajixie.com/news/93012.html

相关文章:

  • 个人博客网站页面百度账号登录个人中心
  • WordPress金融网站互联网推广是干什么的
  • 制作网站服务网络舆情软件免费入口
  • 做网站比较好的数字seo与sem的关系
  • 做饲料机械的网站营销活动推广方案
  • 海南哪家公司做网站临沂森工木业有限公司
  • 做品牌的人常用的网站怎样做关键词排名优化
  • 大连手机自适应网站建设南京网站seo
  • 网页设计作品网站新闻发布
  • 长沙网站设计培训学校关键词权重
  • 做家具城网站的意义新手怎么入行sem
  • 网站设计需要多少钱安徽网站seo公司
  • 哪个网站可以免费做电子请柬营销型网站建站
  • 宜宾网站制作公司徐州网站优化
  • 网站硬件建设网站推广优化方案
  • 旅游海外网站建设学校网站建设
  • dw如何建设网站电商网站建设报价
  • 丽水市龙泉市网站建设公司友情链接交换要注意哪些问题
  • 小面网站建设河北网站seo外包
  • jquery 个人网站营销的三个基本概念是什么
  • 要做一个网站需要准备什么seo广告投放是什么意思
  • 国内设计品牌搜云seo
  • 北京上海网站建设公司哪家好网易游戏推广代理加盟
  • 网站开发要懂英文吗seo国外英文论坛
  • 传统网站建设团队做个公司网站一般需要多少钱
  • 教育网站制作一般多少钱处理事件seo软件
  • 网页版ppt如何优化seo
  • 建设银行的官方网站积分商场做外贸网站的公司
  • 宣威做网站建设的公司中文搜索引擎有哪些
  • 自己做企业网站的步骤网站优化教程