在java中如何定义一个全局变量?
在java中如何定义一个全局变量?
------解决方案--------------------在一个全局类里面定义公共静态变量
public class Global
{
public static int abc = 0;
public static int def = 0;
}
------解决方案-------------------- /**
* <p> Title: Global </p>
* <p> Description: 定义系统中使用的常量 </p>
* <p> Copyright: Copyright (c) 2004 </p>
* <p> Company: hptec </p>
* @author ihavegotyou
* @version 1.0,2004/1/12
*/
public interface Global {
String TIME_FORMAT= "yyyy-MM-dd HH:mm:ss "; //时间格式
String KEY_CONFIG= "infoservice-admin "; //系统配置文件的名字
String APP_CONFIG= "infoservice-app "; //应用程序配置文件
char SPLIT_CHAR= '. ';
String BOARD_MESSAGE= "borad.message "; //board.jsp显示的操作信息
String ERROR_MESSAGE= "您的操作失败! ";
String SUCCESS_MESSAGE= "您的操作成功! ";
String HIBERNATE_SESSION_FACTORY= "hibernate.sessionfactory ";
int PAGESIZE=20;
String REQUEST_SENDMESSAGE= "request_sendmessage ";
//存放由Action生成的业务结果放入request.setAttribute(???,var)
String TABLE_PAYDETAIL_LIST= "table.paydetail.list ";
String TABLE_MESSAGEOUT_LIST= "table.messageout.list ";
String TABLE_MESSAGEIN_LIST= "table.messagein.list ";
String TABLE_MESSAGE_LIST= "table.message.list ";
String TABLE_CONTENT_LIST= "table.content.list ";
String TABLE_SERVICE_LIST= "table.service.list ";
String TABLE_USER2SERVICE_LIST= "table.user2service.list ";
String TABLE_USER2SERVICEOLD_LIST= "table.user2serviceold.list ";
String TABLE_SERVICE_RECORD= "table.service.record ";
String TABLE_USER_RECORD= "table.user.record ";
String INFOMESSAGEOUT_AND_REPORT= "table.messageout.and.report.record ";
String TABLE_LIMITUSER_LIST= "table.limituser.list ";
String TABLE_LIMITCONTENT_LIST= "table.limitcontent.list ";
//存放由Action生成的业务结果的相关信息request.setAttribute(???,var)
String QUERY_INFO_CONTENT_LIST= "query.info.content.list ";
String QUERY_INFO_USER2SERVICE_LIST= "query.info.user2service.list ";
String QUERY_INFO_USER2SERVICEOLD_LIST= "query.info.user2serviceold.list ";
String QUERY_INFO_SERVICE_LIST= "query.info.service.list ";
String QUERY_INFO_MESSAGEOUT_LIST= "query.info.messageout.list ";
String QUERY_INFO_MESSAGEIN_LIST= "query.info.messagein.list ";
String QUERY_INFO_MESSAGE_LIST= "query.info.message.list ";
String QUERY_INFO_PAYDETAIL_LIST= "query.info.paydetail.list ";
String QUERY_LIMITUSER_LIST= "query.limituser.list ";
String QUERY_LIMITCONTENT_LIST= "query.limitcontent.list ";
String QUERY_TCSUBSERVICEBYSP_LIST= "query.tcsubservicebysp.list ";
String QUERY_TCSUBSERVICEBYUSERID_LIST= "query.tcsubservicebyuserid.list ";
}
//接口中的变量默认是final static的