【发布时间】:2013-11-30 05:46:38
【问题描述】:
我正在使用struts 2,并从它的机制中受益,通过它我可以获取和使用request params,同时我声明我的班级的exact names as field variables。
MyClass extends SomeOtherClass {
/** the user id*/
private int userId;
/** the user name*/
private String userName;
// /** java doc description for getters and setters here*/
//getters and setters for userId and userName here
}
mysite.com?userId=3&userName=sarah
直到这里的宇宙运转良好。
现在我有许多(Many)这样的类,它们共享相同的命名字段变量(当然具有不同的值但相同的名称和相同的 javadoc 描述)。
我想将它们的名称和/ javadoc 描述 */ 写在一个地方。**
现在我不能使用继承,因为我已经从其他类扩展,我尝试使用接口。
public interface MyInterface {
/** description from interface for String s */
String s = null;
/** description from interface for int i */
int i = -1;
/** description from interface for boolean b */
boolean b = false;
/** description from interface for getB */
boolean getB();
}
public class Class3 implements MyInterface {
/** description from class 2 for int i */
int i;
/** description from class 2 for getB */
private boolean getB(){
return b;
}
/** description from class 2 for s() */
private String s(){
return null;
}
}
public class Class1 implements MyInterface {
String getS(){
return s;
}
}
问题:
为第 1 类或第 3 类生成的 java 文档不显示任何字段或描述。为什么?
以及考虑到 struts 参数并在一个地方声明公共字段及其描述但使用相同(每个类中具有不同的值和 getter 和 setter)的更好策略的任何好主意
【问题讨论】:
标签: java inheritance struts javadoc