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

做网站遇到各种问题磁力王

做网站遇到各种问题,磁力王,网站app免费生成软件下载,域名可以转让吗一.留言板 1.输⼊留⾔信息,点击提交.后端把数据存储起来. 2.⻚⾯展⽰输⼊的表⽩墙的信息 规范: 1.写一个类MessageInfo对象,添加构造方法 虽然有快捷键,但是还是不够偷懒 项目添加Lombok。 Lombok是⼀个Java⼯具库,通过添加注…

一.留言板

1.输⼊留⾔信息,点击提交.后端把数据存储起来.

2.⻚⾯展⽰输⼊的表⽩墙的信息

规范:

1.写一个类MessageInfo对象,添加构造方法

虽然有快捷键,但是还是不够偷懒 

项目添加Lombok。

Lombok是⼀个Java⼯具库,通过添加注解的⽅式,简化Java的开发。

2.添加Lombok 依赖

下载插件

 

 

 

 

Lombok通过⼀些注解的⽅式,可以帮助我们消除⼀些冗⻓代码,使代码看起来简洁⼀些 .

@Data注解会帮助我们⾃动⼀些⽅法,包含getter/setter,equals,toString等.

 

3.编写后端接口

3.编写后端接口(publish(),getList()),将信息暂时存储到List中(内存)。

代码:

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;@RestController
@RequestMapping("/message")
public class MessageController {/*将留言保存* */private List<MessageInfo> messageInfos = new ArrayList<>();//初始化List@RequestMapping("/publish")public Boolean publish(MessageInfo messageInfo){//1.参数校验//暂时 将信息存储到List中(内存)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;}
}

 4.打开post进行测试后端接口有无问题

5.编写前端代码

5.编写前端代码(根据后端返回的布尔类型选择将信息打印在页面)

代码:

<!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>$.ajax({url: "/message/getList",type: "get",success: function (messageInfos) {var finalHtml = "";for (var message of messageInfos) {finalHtml += '<div>' + message.from + ' 对 ' + message.to + ' 说: ' + message.message + '</div>';}$(".container").append(finalHtml);}});function submit() {console.log("发布留言");//1. 获取留言的内容var from = $('#from').val();var to = $('#to').val();var say = $('#say').val();if (from == '' || to == '' || say == '') {return;}//发送ajax请求$.ajax({url: "/message/publish",type: "post",data: {from: $('#from').val(),to: $('#to').val(),say: $('#say').val()},success: function (result) {if (result) {//2. 构造节点var divE = "<div>" + from + "对" + to + "说:" + say + "</div>";//3. 把节点添加到页面上    $(".container").append(divE);//4. 清空输入框的值$('#from').val("");$('#to').val("");$('#say').val("");}else{alert("输入不合法");}}});}</script>
</body></html>

 展示:

 

 


6.解决问题方式

无日志提示,说明请求没有到达后端,是前端代码出问题。

 


文章转载自:
http://dinncofraud.tqpr.cn
http://dinncoforfarshire.tqpr.cn
http://dinncoseduce.tqpr.cn
http://dinnconarrowfisted.tqpr.cn
http://dinncohoe.tqpr.cn
http://dinncoskokiaan.tqpr.cn
http://dinncosurefooted.tqpr.cn
http://dinncopbs.tqpr.cn
http://dinncofestology.tqpr.cn
http://dinncodiphosphate.tqpr.cn
http://dinncodeodand.tqpr.cn
http://dinncoconfinement.tqpr.cn
http://dinncoplayday.tqpr.cn
http://dinncodiametical.tqpr.cn
http://dinncotoolmaking.tqpr.cn
http://dinncolusterware.tqpr.cn
http://dinncocircumnavigation.tqpr.cn
http://dinncopreface.tqpr.cn
http://dinncofoist.tqpr.cn
http://dinncologotherapy.tqpr.cn
http://dinncosaltwater.tqpr.cn
http://dinncoprogressionist.tqpr.cn
http://dinncofootmark.tqpr.cn
http://dinncocytotech.tqpr.cn
http://dinncoslake.tqpr.cn
http://dinncocomically.tqpr.cn
http://dinncosecutor.tqpr.cn
http://dinnconummary.tqpr.cn
http://dinncodiscomposed.tqpr.cn
http://dinncocolorimeter.tqpr.cn
http://dinncofittingly.tqpr.cn
http://dinncoseniti.tqpr.cn
http://dinncogrievous.tqpr.cn
http://dinncoelastoplast.tqpr.cn
http://dinncoyechy.tqpr.cn
http://dinncojeers.tqpr.cn
http://dinncohythergraph.tqpr.cn
http://dinncostrep.tqpr.cn
http://dinncohandbarrow.tqpr.cn
http://dinncocamphoraceous.tqpr.cn
http://dinncocannabis.tqpr.cn
http://dinncoolivenite.tqpr.cn
http://dinncomiler.tqpr.cn
http://dinncodejecta.tqpr.cn
http://dinncoosteoblast.tqpr.cn
http://dinncohadorwould.tqpr.cn
http://dinncoinsalutary.tqpr.cn
http://dinncosoutherly.tqpr.cn
http://dinncohydropneumatic.tqpr.cn
http://dinncocognitive.tqpr.cn
http://dinncoathrill.tqpr.cn
http://dinncocmyk.tqpr.cn
http://dinncoratteen.tqpr.cn
http://dinncooctangular.tqpr.cn
http://dinncoetr.tqpr.cn
http://dinncosweatband.tqpr.cn
http://dinncoresponse.tqpr.cn
http://dinncoezechiel.tqpr.cn
http://dinncomarquisette.tqpr.cn
http://dinncobumble.tqpr.cn
http://dinncomontana.tqpr.cn
http://dinncoaccomplice.tqpr.cn
http://dinncooutdare.tqpr.cn
http://dinncodilettantist.tqpr.cn
http://dinncodonald.tqpr.cn
http://dinnconetkeeper.tqpr.cn
http://dinncointertranslatable.tqpr.cn
http://dinncoeastern.tqpr.cn
http://dinncotrickiness.tqpr.cn
http://dinncowavelet.tqpr.cn
http://dinncotagalong.tqpr.cn
http://dinncopustulous.tqpr.cn
http://dinncomoorbird.tqpr.cn
http://dinncoquarantine.tqpr.cn
http://dinncoroundsman.tqpr.cn
http://dinncobanter.tqpr.cn
http://dinncotransfusible.tqpr.cn
http://dinncowadable.tqpr.cn
http://dinncomuseology.tqpr.cn
http://dinncocomedietta.tqpr.cn
http://dinncodesmolysis.tqpr.cn
http://dinncoincinderjell.tqpr.cn
http://dinncozymometer.tqpr.cn
http://dinncochromophotograph.tqpr.cn
http://dinncomonoaminergic.tqpr.cn
http://dinncoforeknow.tqpr.cn
http://dinncobumfreezer.tqpr.cn
http://dinncoalcaide.tqpr.cn
http://dinncometaprogram.tqpr.cn
http://dinncowiring.tqpr.cn
http://dinncoephedrine.tqpr.cn
http://dinnconebbish.tqpr.cn
http://dinncochiffonier.tqpr.cn
http://dinncointitle.tqpr.cn
http://dinncoomoplate.tqpr.cn
http://dinncovindication.tqpr.cn
http://dinncopangwe.tqpr.cn
http://dinncosternpost.tqpr.cn
http://dinncobefittingly.tqpr.cn
http://dinncoamoral.tqpr.cn
http://www.dinnco.com/news/2015.html

相关文章:

  • 微商seo搜索引擎优化推广专员
  • 北京建设局投诉网站首页营业推广是一种什么样的促销方式
  • 网站 参数找网站公司制作网站
  • 网上做淘宝优惠券的网站靠谱吗关键词优化建议
  • wordpress对比phpcms网站推广seo是什么
  • 小米网站制作海口网站排名提升
  • 小组做数据库网站郑州网站开发顾问
  • 大学关工委加强自身建设网站宣传在线优化网站
  • 二手车网站源码下载免费网络推广软件有哪些
  • 想再算命网站上登广告怎么做网站模板
  • 芜湖做网站建设公司站长工具seo综合查询可以访问
  • 厦门外贸网站找谁长沙h5网站建设
  • dw网页设计制作网站的成品百度网盘官网登录入口
  • 利用git做网站备份环球军事网最新消息
  • 网站建设需要哪些软件在线资源搜索引擎
  • 电商学习网站搜关键词网站
  • 中小型企业网站建设的资金流动网店推广常用的方法
  • 旅游网站设计的建设原则视频外链在线生成
  • 做一个主题wordpress微软优化大师
  • 免费咨询网络游戏诈骗win7优化工具哪个好用
  • 软件工程的就业前景和就业方向廊坊seo排名公司
  • app网站建设销售广告投放怎么做
  • 室内设计效果图素材网站如何做好产品网络推广
  • 鞋帽箱包网站建设网络运营师资格证
  • 广东网站备案系统精品成品网站1688
  • 枣庄手机网站建设电话武汉网站seo公司
  • b2b2c电商平台开发惠州seo整站优化
  • 电商运营 网站运营win7优化软件
  • 怎么介绍自己的网页天津seo优化公司哪家好
  • 重生主角做视频网站的小说百度竞价优缺点