【SpringBoot中SpringMVC服务之处理post请求】

一.AccountController

复制代码
@RestController
@RequestMapping("account")
public class AccountController extends AbstractGameCenterServerController {

    @Autowired
    private AccountRegisterService accountRegisterService;
    @Autowired
    private AccountService accountLoginService;

    @PostMapping("register")
    public Object registerAccount(@RequestBody AccountRegisterRequest param) throws Exception {
        AccountEntity account = new AccountEntity();
        account.setUsername(param.getUsername());
        account.setPassword(param.getPassword());
        accountRegisterService.accountRegister(account);
        AccountLoginResponse voLoginSuccess = accountLoginService.getLoginResponse(account);
        return responseSuccess(voLoginSuccess);
    }


    @PostMapping("login")
    public Object loginAccount(@RequestBody AccountLoginRequest loginParam) throws Exception {
        AccountEntity account = accountLoginService.login(loginParam);
        AccountLoginResponse loginSuccess = accountLoginService.getLoginResponse(account);
        return responseSuccess(loginSuccess);
    }
}

1.RestController+RequestMapping

2.PostMapping + @RequestBody

相关推荐
BillKu2 小时前
推荐 Eclipse Temurin 的 OpenJDK
java·ide·eclipse
Morri32 小时前
[Java恶补day53] 45. 跳跃游戏Ⅱ
java·算法·leetcode
悟能不能悟2 小时前
eclipse怎么把项目设为web
java·eclipse
乂爻yiyao2 小时前
java 代理模式实现
java·开发语言·代理模式
2301_770373732 小时前
Java集合
java·开发语言
哈喽姥爷3 小时前
Spring Boot---自动配置原理和自定义Starter
java·spring boot·后端·自定义starter·自动配置原理
小蒜学长3 小时前
基于springboot 校园餐厅预约点餐微信小程序的设计与实现(代码+数据库+LW)
数据库·spring boot·微信小程序
老华带你飞4 小时前
考研论坛平台|考研论坛小程序系统|基于java和微信小程序的考研论坛平台小程序设计与实现(源码+数据库+文档)
java·vue.js·spring boot·考研·小程序·毕设·考研论坛平台小程序
CHEN5_024 小时前
leetcode-hot100 11.盛水最多容器
java·算法·leetcode
songx_995 小时前
leetcode18(无重复字符的最长子串)
java·算法·leetcode