我正在构建一个控制器,它接收来自第三方服务的请求.这项服务要求5个参数,我需要绑定到一个Message类.
说,我在请求中,我得到了
?a=x&b=y&c=z&d=w&e=k&f=t
Run Code Online (Sandbox Code Playgroud)
Message类是
public class Message{
String a;
String b;
String c;
String d;
String e;
String f;
public Message(String a, String b, String c, String d, String e, String f){
this.a=a;this.b=b;this.c=c;this.d=d;this.e=e;this.f=f;
}
....// along with getters and setters
}
Run Code Online (Sandbox Code Playgroud)
一种选择是@RequestParam在方法控制器中使用,但随后我必须传递所有参数,然后Message手动实例化对象.我不想这样做,因为参数计数太大.
可以使用init binder/web数据绑定器完成吗?如何?
spring-mvc ×1