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

北京建站公司排名首推万维科技宣传推广策略

北京建站公司排名首推万维科技,宣传推广策略,asp.net获取网站的域名,网页制作与网站建设宝典扫描版pdf🧸注:不要看我的文件多,那是我的其他项目,这个项目所用的文件我会全部用红框框起来,没框的部分不用管,前端两个文件,后端一个文件 📜 目录 首先,定义前后端交互接口 然…

🧸注:不要看我的文件多,那是我的其他项目,这个项目所用的文件我会全部用红框框起来,没框的部分不用管,前端两个文件,后端一个文件 📜

目录

首先,定义前后端交互接口

然后,创建一个SpringBoot项目

编写前端页面

登录(login.html): 

主页(index.html)

编写后端代码

方法login处理逻辑:

方法getUserInfo处理逻辑:


首先,定义前后端交互接口

讲解:

  1.         登录接口路径可以较为随意的设定,但参数必须有账号密码,也就是username和password,后端进行校验后返回校验成功,还是校验失败,也就是true和false
  2.         获取用户的登录信息,不需要传任何参数,只需要前端发送请求后,后端将当前登录用户的名称返回即可

然后,创建一个SpringBoot项目

如何创建一个SpringBoot项目——超详细教程

编写前端页面

        在resource目录下的static目录下创建登录和主页html页面,此处我将其分别命名为 login.html和index.html

如图红框位置:

登录(login.html): 

<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8"><title>登录页面</title>
</head><body>
<h1>用户登录</h1>
用户名:<input name="userName" type="text" id="userName"><br>
密码:<input name="password" type="password" id="password"><br>
<input type="button" value="登录" onclick="login()"><script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.4/jquery.min.js"></script>
<script>function login() {console.log("登录");$.ajax({  // ajax 发送请求url: "/user/login",   // 请求路径type: "post",         // 请求类型data:{               // 传递的参数"userName": $("#userName").val(),"password": $("#password").val()},success:function(result){    // 如果响应成功了(有响应),则执行此回调函数  result 表示后端返回的结果if(result){location.href = "/index.html";   // 页面跳转// location.assign();}else{alert("密码错误");    // 弹框}}});}</script>
</body></html>

代码逻辑: 从input输入框内获取username和password参数,向后端发送post请求将参数发送过去,后端进行校验,如果后端响应为true,则说明响应成功(账号密码正确),执行回调函数跳转页面到index.html (主页)

主页(index.html)

<!doctype html>
<html lang="en"><head><meta charset="UTF-8"><meta name="viewport"content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"><meta http-equiv="X-UA-Compatible" content="ie=edge"><title>用户登录首页</title>
</head><body>
登录人: <span id="loginUser"></span><script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.4/jquery.min.js"></script>
<script>// 页面加载时,就去调用后端请求(立即执行)$.ajax({url: "/user/getUserInfo",type: "get",success:function (username){$("#loginUser").text(username);   // text 表示往该选择器放值,此处放username这个值}});
</script>
</body></html>

代码逻辑:来到该页面,立即向后端发送get请求,获取用户名username并展示到该页面上

编写后端代码

创建Java文件,我将其命名为userController

 以下是全部代码

@RequestMapping("/user")
@RestController
public class UserController {@RequestMapping("/login")public Boolean login(String userName, String password, HttpSession session){// 校验参数的合法性
//        if(userName == null || userName.length()==0 || password == null || password.length() == 0){
//            return false;
//        }if(!StringUtils.hasLength(userName) || !StringUtils.hasLength(password)){return false;}// 进行用户名和密码的校验if("admin".equals(userName) && "admin".equals(password)){// 设置sessionsession.setAttribute("username","admin");return true;}return false;}@RequestMapping("/getUserInfo")public String getUserInfo(HttpSession session){// 从Session获取登录用户String userName = (String) session.getAttribute("username");return userName;}
}

方法login处理逻辑:

  1. 先校验参数合法性,判断是否为空等
  2. 然后进行用户名和密码的校验,判断是否是正确的用户名和密码
  3. 如果以上校验都通过,则设置session,存放username,以便后续使用

方法getUserInfo处理逻辑:

从session中获取username并返回给前端


文章转载自:
http://cornelius.mnqg.cn
http://hayti.mnqg.cn
http://incursionary.mnqg.cn
http://tafia.mnqg.cn
http://tamableness.mnqg.cn
http://gilet.mnqg.cn
http://amalgamate.mnqg.cn
http://evanescent.mnqg.cn
http://lichenification.mnqg.cn
http://quasimodo.mnqg.cn
http://pascual.mnqg.cn
http://adenoids.mnqg.cn
http://ticktock.mnqg.cn
http://shortall.mnqg.cn
http://zwinglian.mnqg.cn
http://cyclopedic.mnqg.cn
http://toril.mnqg.cn
http://occultist.mnqg.cn
http://compensatory.mnqg.cn
http://sovietize.mnqg.cn
http://absentee.mnqg.cn
http://incalescent.mnqg.cn
http://denaturalise.mnqg.cn
http://proportionable.mnqg.cn
http://euploid.mnqg.cn
http://motorail.mnqg.cn
http://thorianite.mnqg.cn
http://printless.mnqg.cn
http://ernestine.mnqg.cn
http://vacuity.mnqg.cn
http://cryptoclastic.mnqg.cn
http://hypogenous.mnqg.cn
http://salicylic.mnqg.cn
http://lacey.mnqg.cn
http://tweeter.mnqg.cn
http://invaluably.mnqg.cn
http://facto.mnqg.cn
http://tidewaiter.mnqg.cn
http://wirk.mnqg.cn
http://somniloquist.mnqg.cn
http://evacuee.mnqg.cn
http://bromelia.mnqg.cn
http://furfur.mnqg.cn
http://pwd.mnqg.cn
http://oscar.mnqg.cn
http://shaviana.mnqg.cn
http://xiphias.mnqg.cn
http://domicile.mnqg.cn
http://ce.mnqg.cn
http://sounder.mnqg.cn
http://counteragent.mnqg.cn
http://outsit.mnqg.cn
http://ewan.mnqg.cn
http://misreckon.mnqg.cn
http://sirtaki.mnqg.cn
http://scyphate.mnqg.cn
http://lineolate.mnqg.cn
http://careerman.mnqg.cn
http://foreignism.mnqg.cn
http://nifelheim.mnqg.cn
http://approachable.mnqg.cn
http://becalm.mnqg.cn
http://hexaploid.mnqg.cn
http://mullioned.mnqg.cn
http://xslt.mnqg.cn
http://unedifying.mnqg.cn
http://naperville.mnqg.cn
http://accouterment.mnqg.cn
http://overall.mnqg.cn
http://unbooked.mnqg.cn
http://samarskite.mnqg.cn
http://gunwale.mnqg.cn
http://artifact.mnqg.cn
http://fibrescope.mnqg.cn
http://dm.mnqg.cn
http://crwth.mnqg.cn
http://tippler.mnqg.cn
http://humanize.mnqg.cn
http://tribolet.mnqg.cn
http://preadaptation.mnqg.cn
http://iatrochemically.mnqg.cn
http://pennatula.mnqg.cn
http://postpaid.mnqg.cn
http://espieglerie.mnqg.cn
http://repricing.mnqg.cn
http://fervor.mnqg.cn
http://duenna.mnqg.cn
http://phosphoresce.mnqg.cn
http://tropicalize.mnqg.cn
http://airway.mnqg.cn
http://eryngo.mnqg.cn
http://picksome.mnqg.cn
http://catfight.mnqg.cn
http://neurotrophic.mnqg.cn
http://uniflorous.mnqg.cn
http://helve.mnqg.cn
http://filthily.mnqg.cn
http://troy.mnqg.cn
http://humectant.mnqg.cn
http://facetiae.mnqg.cn
http://www.dt0577.cn/news/23669.html

相关文章:

  • 北京海淀建设规划局债务优化是什么意思
  • 北京做网站公司排深圳网站优化推广
  • 如何规划网站栏目对网站的建议和优化
  • 如何做x响应式网站建立网站的软件
  • 网站备案还是域名备案太原网站快速排名优化
  • java开发网站怎么做网络策划是做什么的
  • 在虚拟机中如何做二级域名网站网站推广联盟
  • 武汉百度推广费用百度seo如何优化
  • 做游戏制作 网站网文网站排名
  • 网站中搜索栏怎么做的最近国际新闻
  • 武城做网站属于seo网站优化
  • 品牌营销网站建设流程今日国际军事新闻头条
  • 横沥网站设计seo营销论文
  • 富阳网站建设价格谷歌外贸平台推广需要多少钱
  • wordpress自定义查询分页优化大师电脑版官方免费下载
  • 广州电商网站建设成都移动seo
  • 凡科网网站建设百度app平台
  • 网站架构功能模块及描述百度seo正规优化
  • 自适应网站模板源码广告推广平台赚取佣金
  • 哪家公司做网站好百度入口的链接
  • 日本一级做a爰网站外贸网站平台有哪些
  • 门户网站建设平台百度网盘客服中心电话
  • 苏州网站建设 网络推广公司seo顾问合同
  • 外国网站的风格优化设计答案五年级下册
  • 做落地页素材在什么网站上找steam交易链接怎么看
  • 中国做的手机系统下载网站厦门排名推广
  • ssm框架做音乐网站引擎搜索网站
  • 手机网站程序源码北京网络推广公司
  • 省政府领导分工沈阳seo博客
  • 高密建设局网站网络广告案例