【发布时间】:2014-07-22 14:38:21
【问题描述】:
我的问题似乎很好奇,因为我是 Java 新手。
我已经阅读了关于 Java 中注释的 oracle lesson。但我还不明白他们在实践中是如何工作的。考虑以下spring framework 4.0.1 定义的注解:
@Target(value = {ElementType.PARAMETER})
@Retention(value = RetentionPolicy.RUNTIME)
@Documented
public @interface RequestParam {
public String value() default "";
public boolean required() default true;
public String defaultValue() default "\n\t\t\n\t\t\n\ue000\ue001\ue002\n\t\t\t\t\n";
}
注释可能适用于如下函数参数
public void change(@RequestParam("id") String id, @RequestParam("cost") String cost, @RequestParam("name") String name, Model model) throws SQLException, UnsupportedEncodingException {
//id will have the value of param id, passing inside request
//but ***I have no explicitly assignation*** requested parameter
//to the function parameter
}
谁将请求的参数值准确地分配给相应的函数参数?
【问题讨论】:
标签: java spring annotations