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

开封专业做网站公司wordpress图片上传慢

开封专业做网站公司,wordpress图片上传慢,最好的ppt模板网站,小程序代运营怎么收费Spring留言板实现 预期结果 可以发布并显示点击提交后,显示并清除输入框并且再次刷新后,不会清除下面的缓存 约定前后端交互接口 Ⅰ 发布留言 url : /message/publish . param(参数) : from,to,say . return : true / false . Ⅱ 查询留言 url : /messag…

Spring留言板实现

预期结果

  • 可以发布并显示
  • 点击提交后,显示并清除输入框
  • 并且再次刷新后,不会清除下面的缓存

约定前后端交互接口

Ⅰ 发布留言
url : /message/publish .
param(参数) : from,to,say .
return : true / false .

 Ⅱ 查询留言
url : /message/getList.
param : 无
return : form 对 to 说了 say

后端代码

MessageInfo类代码

import lombok.Data;@Data
public class MessageInfo {private String from;private String to;private String say;
}

我们这里发现这样有个注释@Data ,

它的作用是可以让我们少写一些代码,我们通过反编译看看:

import lombok.Generated;public class MessageInfo {private String from;private String to;private String say;@Generatedpublic MessageInfo() {}@Generatedpublic String getFrom() {return this.from;}@Generatedpublic String getTo() {return this.to;}@Generatedpublic String getSay() {return this.say;}@Generatedpublic void setFrom(final String from) {this.from = from;}@Generatedpublic void setTo(final String to) {this.to = to;}@Generatedpublic void setSay(final String say) {this.say = say;}@Generatedpublic boolean equals(final Object o) {if (o == this) {return true;} else if (!(o instanceof MessageInfo)) {return false;} else {MessageInfo other = (MessageInfo)o;if (!other.canEqual(this)) {return false;} else {label47: {Object this$from = this.getFrom();Object other$from = other.getFrom();if (this$from == null) {if (other$from == null) {break label47;}} else if (this$from.equals(other$from)) {break label47;}return false;}Object this$to = this.getTo();Object other$to = other.getTo();if (this$to == null) {if (other$to != null) {return false;}} else if (!this$to.equals(other$to)) {return false;}Object this$say = this.getSay();Object other$say = other.getSay();if (this$say == null) {if (other$say != null) {return false;}} else if (!this$say.equals(other$say)) {return false;}return true;}}}@Generatedprotected boolean canEqual(final Object other) {return other instanceof MessageInfo;}@Generatedpublic int hashCode() {int PRIME = true;int result = 1;Object $from = this.getFrom();result = result * 59 + ($from == null ? 43 : $from.hashCode());Object $to = this.getTo();result = result * 59 + ($to == null ? 43 : $to.hashCode());Object $say = this.getSay();result = result * 59 + ($say == null ? 43 : $say.hashCode());return result;}@Generatedpublic String toString() {String var10000 = this.getFrom();return "MessageInfo(from=" + var10000 + ", to=" + this.getTo() + ", say=" + this.getSay() + ")";}
}

那么如何使用这个注释呢?我们如果直接使用这个注释的话,我们自己电脑上是没有的,所以我们需要引入一个插件:lombok:

然后刷新一下maven;

当我们继续使用@Data的时候,我们发现还是不能进行使用

这是因为随着spring更新的原因,导致这个插件的失效,我们只要删除以下代码就行

然后我们就可以使用了

当然,如果我们只想使用个别的代码,比如setter,getter...,我们可以特别处理,我们这里先不予讲解,大家有兴趣的自己去了解一下即可

 MessageContraller代码

package com.example.demo;import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;import java.util.ArrayList;
import java.util.List;@RequestMapping("/message")
@RestController
public class MessageController {List<MessageInfo> messageInfos = new ArrayList<>();@RequestMapping("/publish")public Boolean publish(MessageInfo messageInfo) {//校验信息if(!StringUtils.hasLength(messageInfo.getFrom())|| !StringUtils.hasLength(messageInfo.getTo())|| !StringUtils.hasLength(messageInfo.getSay())) {return false;}//把信息存起来方便下一个方法获取messageInfos.add(messageInfo);return true;}@RequestMapping("/getList")public List<MessageInfo> getList() {return messageInfos;}
}

前端代码 

<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>留言板</title><style>.container {width: 350px;height: 300px;margin: 0 auto;/* border: 1px black solid; */text-align: center;}.grey {color: grey;}.container .row {width: 350px;height: 40px;display: flex;justify-content: space-between;align-items: center;}.container .row input {width: 260px;height: 30px;}#submit {width: 350px;height: 40px;background-color: orange;color: white;border: none;margin: 10px;border-radius: 5px;font-size: 20px;}</style>
</head><body><div class="container"><h1>留言板</h1><p class="grey">输入后点击提交, 会将信息显示下方空白处</p><div class="row"><span>谁:</span> <input type="text" name="" id="from"></div><div class="row"><span>对谁:</span> <input type="text" name="" id="to"></div><div class="row"><span>说什么:</span> <input type="text" name="" id="say"></div><input type="button" value="提交" id="submit" onclick="submit()"><!-- <div>A 对 B 说: hello</div> --></div><script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.4/jquery.min.js"></script><script>function submit() {$.ajax({url: "/message/publish",type: "post",data: {from: $("#from").val(),to: $("#to").val(),say: $("#say").val()},//http响应成功success:function(result) {if(result == false) {alert("输入不合法");}else {//展示信息//1. 构造节点//3. 清空输入框的值$("#from").val("");$("#to").val("");$("#say").val("");}}});$.ajax({url: "/message/getList",type: "get",success: function(result) {if(result!=null&&result.length>0) {for(x of result) {var divE = "<div>"+x.from+ "对" + x.to + "说:" + x.say + "</div>";$(".container").append(divE);}}}})}</script>
</body></html>

结果展示


文章转载自:

http://t56lOGCb.pyxtn.cn
http://xYAvoPqF.pyxtn.cn
http://cfFB0g7G.pyxtn.cn
http://joWjftne.pyxtn.cn
http://RnoSYt5Q.pyxtn.cn
http://gbka5XJt.pyxtn.cn
http://nH0jIgR0.pyxtn.cn
http://83WhR5r3.pyxtn.cn
http://wxBYsSy9.pyxtn.cn
http://mGBvrkvr.pyxtn.cn
http://ewzE6l7p.pyxtn.cn
http://DhLz5zoL.pyxtn.cn
http://z5Vcrw6A.pyxtn.cn
http://RIKiTE0o.pyxtn.cn
http://ctrSfMPR.pyxtn.cn
http://1YfFZWVv.pyxtn.cn
http://3K2cgKDF.pyxtn.cn
http://oOuPpWGG.pyxtn.cn
http://wrr8ahQq.pyxtn.cn
http://NfZekISg.pyxtn.cn
http://VsVqjfXH.pyxtn.cn
http://jZkVwDpo.pyxtn.cn
http://MfJq1qOr.pyxtn.cn
http://D4Agq15S.pyxtn.cn
http://U0DoaBT3.pyxtn.cn
http://yalhpMYV.pyxtn.cn
http://nPLX9sDC.pyxtn.cn
http://R4kLHHlH.pyxtn.cn
http://vy0Q7CXF.pyxtn.cn
http://Eu2eP5Rf.pyxtn.cn
http://www.dtcms.com/wzjs/777318.html

相关文章:

  • 苏州网站推广服务沈阳商城网站开发
  • error 403 网站拒绝显示django网站开发视频教程
  • 人社门户网站建设方案网站开发设计流程时间表
  • 贵州网站制作公司建立网站的元素有哪些
  • 网站排名点击工具做宠物网站导航应该写什么字
  • 电子商务网站建设运行环境舟山 做企业网站
  • 盘锦建设小学网站net域名大网站
  • 上海哪家做公司网站如何提高网站内容质量
  • 一元夺宝网站建设2017珠宝行网站建设方案
  • 企业网站建设有什么义县网站建设
  • 网站建设不完整 审核线上企业订单管理系统网站
  • wordpress 换域名 全站301重定向做seo_教你如何选择网站关键词
  • 计算机网络技术网站开发wordpress网站关键字
  • 百姓网网站建设网站开发用php还是js
  • 如何建学校网站wordpress动态插件
  • 广州建设厅电工网站江门建站网站模板
  • 树苗网站源码什邡建设局网站
  • 美文的手机网站淘宝客网站一定要备案
  • 域名注册网站 简称十堰公司做网站
  • 博客做公司网站北京建站公司兴田德润信任
  • 网站开发学哪一个好公关公司多少钱一个月
  • 有视频接口怎么做网站课题组网站建设
  • 济宁网站建设只要500元wordpress瀑布墙
  • 东莞网站建设咨询外贸做企业什么网站
  • 小说网站建设需要什么js跳转到别的网站
  • 婚纱定制网站哪个好韶关网站开发
  • 昆明网站制作企业海淘手表网站
  • 深圳wap网站建设7天精通网站建设实录简介242
  • 中国建设银行个人网站银行广州专业网页制作
  • 建设银行 北京招聘网站开购物网站需要多少钱