最近在手撸框架的时候遇到了比较迷惑的bug:利用反射获取Controller类中方法的参数列表,然后取出参数名,从前端传回来的数据中找到对应的值注入;这时候除了异常,打了断点发现hello()方法的两个参数名为 arg0 和 arg1,导致了参数注入失败。
import org.apache.commons.lang3.ArrayUtils;
import java.lang.reflect.Method;
import java.lang.reflect.Parameter;
public class ParameterTest {
public void hello(String username, String password){
System.out.println("hello");
System.out