The following bean could be used:
public class MyConfigBean {
private static String firstName;
public void setFirstName(String inFirstName) {
firstName = inFirstName;
}
public String getFirstName() {
return firstName;
}
} 在应用中你不用去自己解析xml了,javawebparts已经帮你做好了,你只要getFirstName()就可以了,是不是很方便?
你所要做的工作就是在web.xml中引用一个listener,配置如下:
<TextReturnerServletItems>
<item>0 - It's always darkest before the dawn</item>
<item>1 - A journey of a thousand miles begins with a single step</item>
<item>2 - The universe is like stupidity: both are infinite and actually, I'm not sure about the universe</item>
<item>3 - I believe there is intelligent life in the universe, except for some parts of New Jersey</item>
<item>4 - If your falling of a cliff, you might as well try and fly</item>
<item>5 - The cost of life is to chance the consequence</item>
</TextReturnerServletItems>