为什么一直都是异常
来源:5-1 获取用户OpenId
土豆love洋芋
2020-05-31 23:17:55
package com.example.missyou.api.v1;
import com.example.missyou.dto.TokenGetDTO;
import com.example.missyou.exception.http.NotFoundException;
import com.example.missyou.service.WxAuthenticationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.Map;
@RequestMapping(value = "token")
@RestController
public class TokenController {
@Autowired
private WxAuthenticationService wxAuthenticationService;
@PostMapping("")
public Map<String,String> getToken(@RequestBody @Validated TokenGetDTO userData){
Map<String,String> map=new HashMap<>();
String token=null;
switch (userData.getType()){
case USER_WX:
wxAuthenticationService.code2Session(userData.getAccount());
break;
case USER_Email:
break;
default:
throw new NotFoundException(10003);
}
return null;
}
}
Debeg 无法进入这个段代码,直接就跳入DTO,如果不打这个注解 @Validated可以进入这个代码,可以获取数据。。。怎么回事啊
1回答
7七月
2020-06-01
进入DTO就说明 传入参数不正确吧。可以再看下课程或者直接对比下源码
相似问题