


When the front-end passes data to the back-end, the back-end displays that the obtained data is NULL. How to solve it?
Apr 19, 2025 pm 09:15 PMProblem Description: During the development process of using the Ruoyi separate framework, the front-end uses POST request to pass data to the back-end, but the back-end receives a NULL value.
Front-end code:
//Modify the order status export function updateorderstatus(id,status){ const data={ id, status } return request({ url:"/business/orderinfo/updatestate", method:"post", data:data }) }
Screenshot of front-end request data: (Screenshot of front-end request data should be included here)
Backend code (original code):
@ApiOperation("Order Management-Modify Order Status") @ApiImplicitParams({ @ApiImplicitParam(name="id", value = "primary key id", required = true, dataType = "integer"), @ApiImplicitParam(name="status", value = "Status 0 ends with 1", required = true, dataType = "integer") }) @PostMapping("/updatestate") public AjaxResult updateState(Integer id, Integer status) { System.out.println("Change Order Number: "id "\n"); System.out.println("Change order status: " status "\n"); // ... (Other code) }
Screenshot of backend printing results: (This should include screenshots of backend printing results, showing id and status as null)
Problem analysis: The backend uses Integer id, Integer status
to receive parameters. When processing POST requests, Spring Boot cannot correctly parse JSON data in the request body to these parameters by default.
Solution: Modify the backend code and bind the JSON data in the request body to an object using the @RequestBody
annotation.
Modified backend code:
@ApiOperation("Order Management-Modify Order Status") @PostMapping("/updatestate") public AjaxResult updateState(@RequestBody OrderStatusDTO orderStatusDTO) { System.out.println("Change Order Number:" orderStatusDTO.getId() "\n"); System.out.println("Change order status:" orderStatusDTO.getStatus() "\n"); if (orderStatusDTO.getId() == null) { return AjaxResult.error("enter primary key id"); } if (orderStatusDTO.getStatus() == null) { return AjaxResult.error("Input Status"); } BorderInfo borderInfo = new BorderInfo(); borderInfo.setId(orderStatusDTO.getId()); borderInfo.setStatus(orderStatusDTO.getStatus()); System.out.println("Change order status:" borderInfo.toString() "\n"); orderInfoService.update(borderInfo); return AjaxResult.success(); }
Added OrderStatusDTO class:
public class OrderStatusDTO { private Integer id; private Integer status; // getters and setters }
By using @RequestBody
annotation and creating an OrderStatusDTO
class to receive the JSON data passed by the front end, the backend can correctly parse the data to avoid the problem of NULL
values. Please make sure that the JSON data sent by the front end is consistent with the field name of OrderStatusDTO
. At the same time, check whether the front-end request
function has correctly set headers
, such as Content-Type: application/json
.
This solution is more in line with the design specifications of the RESTful API than the original @RequestParam
solution, and also processes the body data of POST requests more clearly.
The above is the detailed content of When the front-end passes data to the back-end, the back-end displays that the obtained data is NULL. How to solve it?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Yes, you can get USDT for free in the following 5 ways: 1. Participate in airdrop tasks on mainstream exchanges, such as registering and giving away, completing novice tasks, and inviting friends to get rewards; 2. Join the blockchain project community and obtain airdrops through Web3 social platform or Twitter/Discord interaction; 3. Participate in the "test network" activity, register the test chain address and simulate the use of DApp to get incentives; 4. Complete tasks on the cryptocurrency navigation platform to receive novice gift packages, participate in sign-in, lottery and other activities; 5. Interact with the content creation and community, and publish original content to obtain USDT rewards from the project party. At the same time, you need to pay attention to security risks, do not fill in private keys, do not believe in scams, and choose mainstream platforms to participate.

?As a stable digital asset pegged to the US dollar, USDT's value conversion and monetization are issues that many users are concerned about. This article will introduce the value composition of USDT in detail and provide practical tutorials on value conversion and monetization in mainland China. 1 USDT's cash value is approximately equal to the real-time dollar exchange rate, but the final delivery price through C2C trading will fluctuate slightly. The core of conversion is to select a merchant with good reputation and appropriate price to trade through the C2C function of a reliable platform.

USDT is not a scam, but there are risks. 1. Tether provides liquidity in the crypto market by issuing USDT, a stablecoin anchored by the US dollar; 2. The company's background is related to Bitfinex, and has been fined for audit issues but has increased transparency; 3. The reserve assets are mainly US Treasury bonds rather than pure cash, and there are certain financial risks; 4. Face risks such as insufficient audit frequency, centralized control and compliance restrictions; 5. The USDT market is highly accepted, but trust needs to be based on continuous disclosure and compliance operations. Overall, USDT is trustworthy but does not equal zero risk, and users should be cautious.

USDT cash exchange needs to be operated through a trading platform that supports fiat currency withdrawal. 1. Prepare a trading platform account that supports fiat currency withdrawal (such as Binance, Ouyi, Huobi, etc.); 2. Complete KYC real-name authentication; 3. Bind bank cards or Alipay and other payment methods; 4. Log in to the account and ensure that USDT is in the fund account or spot account; 5. Enter the OTC or fiat currency area and choose to sell USDT; 6. Set the sales amount and match the buyer; 7. After confirming the other party’s payment, click “Confirm Coin Delivery” to complete the transaction. Withdrawal methods include OTC fiat currency transactions, bank card withdrawals and third-party payments, among which OTC is more efficient. Notes include making sure to verify that the money is received before releasing, avoiding frequent large withdrawals, and contacting customer service in time when encountering abnormalities. The key to the entire process is to choose

The "reverse reference" in the currency circle, as the name suggests, refers to those reference objects whose views or operations are often opposite to the actual market trend. When such people or groups are extremely optimistic, the market may face a decline; when they are extremely pessimistic, the market may instead rebound. This is not to say that these people deliberately provide wrong signals, but that their judgments may deviate from the mainstream trends in the market, or that their operating behavior happens to be a catalyst for market reversal in a specific situation.

NALA coins can be traded on platforms such as Uniswap V2 (Ethereum Network), Uniswap V3 (Base Network), MEXC and CoinUnited.io. The specific steps are: 1. Select a trading platform; 2. Register and complete identity verification; 3. Recharge funds; 4. Purchase NALA; 5. Withdraw coins to your personal wallet. Please ensure the security of the platform before investing and pay attention to market volatility risks.

To transfer USDT to the exchange for transactions, you must first confirm that the chain type matches, the address is correct, and complete real-name authentication. 1. Register and authenticate the mainstream exchange account with real name; 2. Confirm that the wallet is consistent with the USDT chain type of the exchange (such as TRC20); 3. Obtain the recharge address of the corresponding chain on the exchange and copy it accurately; 4. Initiate transfers from the wallet and pay the corresponding handling fee; 5. After arrival, you can trade in the spot or contract market; 6. Pay attention to checking the address, avoid transferring to the contract address, and give priority to low-processing networks. The entire process is usually completed in minutes, ensuring operational safety is key.

Finding airdrop opportunities for cryptocurrency projects is the way many participants want to acquire tokens for early-stage projects. These airdrops are usually a means for project parties to promote brand, community construction, or inspire early users. To find this information effectively, you need to rely on multiple reliable channels and methods.
