在struts中,如果使用 bean:message会显示出来资源文件中定义的内容,如果不是用标签,用编程的方式得到资源内容:
import javax.servlet.jsp.PageContext;
import org.apache.struts.taglib.TagUtils;
/**
* @author Administrator
* Window - Preferences - Java - Code Style - Code Templates
*/
public class Message {
private PageContext context=null;
private static TagUtils util=TagUtils.getInstance();;
public Message(PageContext context);{
this.context=context;
}
/**
* 返回key 的值
* @param context
* @param key
* @return
*/
public static String getMessage(PageContext context,String key);{
String value="";
try{
value=util.message(context,null,null,key);;
}catch(Exception e);{
return value;
}
return value;
}
public String getMessage(String key);{
String value="";
try{
value=util.message(context,null,null,key);;
}catch(Exception e);{
return value;
}
return value;
}............