亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

Home Java javaTutorial When the front-end passes data to the back-end, the back-end displays that the obtained data is NULL. How to solve it?

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 PM
usdt red

When the front-end passes data to the back-end, the back-end displays that the obtained data is NULL. How to solve it?

Problem 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!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to use PHP combined with AI to achieve text error correction PHP syntax detection and optimization How to use PHP combined with AI to achieve text error correction PHP syntax detection and optimization Jul 25, 2025 pm 08:57 PM

To realize text error correction and syntax optimization with AI, you need to follow the following steps: 1. Select a suitable AI model or API, such as Baidu, Tencent API or open source NLP library; 2. Call the API through PHP's curl or Guzzle and process the return results; 3. Display error correction information in the application and allow users to choose whether to adopt it; 4. Use php-l and PHP_CodeSniffer for syntax detection and code optimization; 5. Continuously collect feedback and update the model or rules to improve the effect. When choosing AIAPI, focus on evaluating accuracy, response speed, price and support for PHP. Code optimization should follow PSR specifications, use cache reasonably, avoid circular queries, review code regularly, and use X

PHP calls AI intelligent voice assistant PHP voice interaction system construction PHP calls AI intelligent voice assistant PHP voice interaction system construction Jul 25, 2025 pm 08:45 PM

User voice input is captured and sent to the PHP backend through the MediaRecorder API of the front-end JavaScript; 2. PHP saves the audio as a temporary file and calls STTAPI (such as Google or Baidu voice recognition) to convert it into text; 3. PHP sends the text to an AI service (such as OpenAIGPT) to obtain intelligent reply; 4. PHP then calls TTSAPI (such as Baidu or Google voice synthesis) to convert the reply to a voice file; 5. PHP streams the voice file back to the front-end to play, completing interaction. The entire process is dominated by PHP to ensure seamless connection between all links.

PHP realizes commodity inventory management and monetization PHP inventory synchronization and alarm mechanism PHP realizes commodity inventory management and monetization PHP inventory synchronization and alarm mechanism Jul 25, 2025 pm 08:30 PM

PHP ensures inventory deduction atomicity through database transactions and FORUPDATE row locks to prevent high concurrent overselling; 2. Multi-platform inventory consistency depends on centralized management and event-driven synchronization, combining API/Webhook notifications and message queues to ensure reliable data transmission; 3. The alarm mechanism should set low inventory, zero/negative inventory, unsalable sales, replenishment cycles and abnormal fluctuations strategies in different scenarios, and select DingTalk, SMS or Email Responsible Persons according to the urgency, and the alarm information must be complete and clear to achieve business adaptation and rapid response.

Twilio call keeping and recovery: Meeting mode with independent call leg processing Twilio call keeping and recovery: Meeting mode with independent call leg processing Jul 25, 2025 pm 08:42 PM

This article elaborates on two main methods to realize call hold and unhold in Twilio. The preferred option is to leverage Twilio's Conference feature to easily enable call retention and recovery by updating the conference participant resources, and to customize music retention. Another approach is to deal with independent call legs, which requires more complex TwiML logic, passed, and arrived management, but is more cumbersome than meeting mode. The article provides specific code examples and operation steps to help developers efficiently implement Twilio call control.

How to choose a free market website in the currency circle? The most comprehensive review in 2025 How to choose a free market website in the currency circle? The most comprehensive review in 2025 Jul 29, 2025 pm 06:36 PM

The most suitable tools for querying stablecoin markets in 2025 are: 1. Binance, with authoritative data and rich trading pairs, and integrated TradingView charts suitable for technical analysis; 2. Ouyi, with clear interface and strong functional integration, and supports one-stop operation of Web3 accounts and DeFi; 3. CoinMarketCap, with many currencies, and the stablecoin sector can view market value rankings and deans; 4. CoinGecko, with comprehensive data dimensions, provides trust scores and community activity indicators, and has a neutral position; 5. Huobi (HTX), with stable market conditions and friendly operations, suitable for mainstream asset inquiries; 6. Gate.io, with the fastest collection of new coins and niche currencies, and is the first choice for projects to explore potential; 7. Tra

What is a stablecoin? Understand stablecoins in one article! What is a stablecoin? Understand stablecoins in one article! Jul 29, 2025 pm 01:03 PM

Stablecoins are cryptocurrencies with value anchored by fiat currency or commodities, designed to solve price fluctuations such as Bitcoin. Their importance is reflected in their role as a hedging tool, a medium of trading and a bridge connecting fiat currency with the crypto world. 1. The fiat-collateralized stablecoins are fully supported by fiat currencies such as the US dollar. The advantage is that the mechanism is simple and stable. The disadvantage is that they rely on the trust of centralized institutions. They represent the projects including USDT and USDC; 2. The cryptocurrency-collateralized stablecoins are issued through over-collateralized mainstream crypto assets. The advantages are decentralization and transparency. The disadvantage is that they face liquidation risks. The representative project is DAI. 3. The algorithmic stablecoins rely on the algorithm to adjust supply and demand to maintain price stability. The advantages are that they do not need to be collateral and have high capital efficiency. The disadvantage is that the mechanism is complex and the risk is high. There have been cases of dean-anchor collapse. They are still under investigation.

How to check the real-time prices of USDT and USDC? The most complete stablecoin app guide in 2025 How to check the real-time prices of USDT and USDC? The most complete stablecoin app guide in 2025 Jul 29, 2025 pm 06:42 PM

Binance App provides millisecond updated real-time trading prices of stablecoins such as USDT and USDC, which is the benchmark reference for the world's largest trading market; 2. Ouyi App not only displays precise market conditions, but also supports the linkage of technical analysis and financial products, suitable for in-depth traders; 3. Huobi (HTX) App has a wide influence in the Asian market, and its C2C quotation provides an important basis for off-market prices; 4. Gate.io App has rich coins listed, suitable for users who pay attention to mainstream and emerging stablecoins; 5. CoinMarketCap aggregates the weighted average prices of global exchanges, providing comprehensive data and historical charts, suitable for macro analysis; 6. CoinGecko evaluates exchanges and assets with trust scores, with a wider data dimension, and is a market.

Ethena treasury strategy: the rise of the third empire of stablecoin Ethena treasury strategy: the rise of the third empire of stablecoin Jul 30, 2025 pm 08:12 PM

The real use of battle royale in the dual currency system has not yet happened. Conclusion In August 2023, the MakerDAO ecological lending protocol Spark gave an annualized return of $DAI8%. Then Sun Chi entered in batches, investing a total of 230,000 $stETH, accounting for more than 15% of Spark's deposits, forcing MakerDAO to make an emergency proposal to lower the interest rate to 5%. MakerDAO's original intention was to "subsidize" the usage rate of $DAI, almost becoming Justin Sun's Solo Yield. July 2025, Ethe

See all articles