freemarker相对路径和记录当前时间

 

< href ="${request.getContextPath()}/allTerritory.action"   > 论坛 </ A ></ TD >  

${request.getContextPath()}这个是根目录路径

显示当前时间:

Calendar time  =  Calendar.getInstance();
int  hour  =  time.get(Calendar.HOUR_OF_DAY);
int  minute  =  time.get(Calendar.MINUTE); 
int  year  =  time.get(Calendar.YEAR); 
int  day  =  time.get(Calendar.DAY_OF_MONTH);    
int  month  =  time.get(Calendar.MONTH)  +   1 ;    
String t 
=   ""   +  year  +   " - "   +  month  +   " - "   +  day  +   " - "   +  hour  +   " : "       +  minute; 

这个是现在用的。网上查到另一种方法:

SimpleDateFormat tempDate  =   new  SimpleDateFormat( " yyyy-MM-dd "   +   "   "   +   " hh:mm:ss " ); 
String datetime 
=  tempDate.format( new  java.util.Date());

你可能感兴趣的:(freemarker)