In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces the steps of WeChat Mini Programs's back-end Java interface development, the content is very detailed, interested friends can refer to, hope to be helpful to you.
WeChat Mini Programs uses wx.request (OBJECT) to call the backend interface.
First of all, let's take a simple case-- helloworld implementation.
1. Build a springboot project and introduce dependencies
Org.springframework.boot spring-boot-starter-web 2. Write the controller layer @ RestControllerpublic class HelloWorldController {@ GetMapping ("/ helloWorld") public String helloWorld (Integer id) {return "helloworld" + id;}} server: port: 80 servlet: context-path: / tomcat: uri-encoding: utf-8
Run successfully
3. Create WeChat Mini Programs project
Helloworld.js
/ * initial data of the page * / data: {result:' request backend.'}, / * Lifecycle function-- listen for page loading * / onLoad: function (options) {var that=this; this.getData (that) }, getData (that) {wx.request ({url: 'http://localhost:8080/helloWorld', method:'GET', data: {id:666}, header: {' content-type':'application/json' / / default}) Success (res) {console.log (res.data) Console.log (that); that.setData ({result:res.data})})}
Helloworld.wxml
Data returned by backend: {{result}}
Attention:!
Remember to set up the following figure here
Otherwise, an error will be reported:
VM9 asdebug.js:1 http://localhost is not in the following request
In the list of legitimate domain names, please refer to the document: https://developers.weixin.qq.com/miniprogram/dev/framework/ability/network.html(env:
Windows,mp,1.05.2110110; lib: 2.19.4)
The successful access to the backend is as follows
On WeChat Mini Programs back-end Java interface development steps are shared here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.