有这样一个问题:
在JSP页面中我调用一个法,因为页面是用 struts 标签写的这样调用的话就不可以了 getTimeEqualw(${nowTime},${oldTime})为什么这里调用不能使用 EL 表达试呢,有没有什么好的方法呢?

解决方案 »

  1.   

    把你的页面头部加入下面内容
    <%@ taglib prefix="bean"  uri="http://struts.apache.org/tags-bean" %>
    <%@ taglib prefix="logic"  uri="http://struts.apache.org/tags-logic" %>
    <%@ taglib prefix="html"  uri="http://struts.apache.org/tags-html" %>
    <%@ taglib prefix="c"  uri="http://java.sun.com/jsp/jstl/core" %>
    <%@ taglib prefix="fmt"  uri="http://java.sun.com/jsp/jstl/fmt" %>
    <%@ taglib prefix="pg"  uri="http://jsptags.com/tags/navigation/pager" %>
    <%@ taglib prefix="fn"  uri="http://java.sun.com/jsp/jstl/functions"%>
      

  2.   

    如果是struts2的话就不用加那么多的标签
      

  3.   

    getTimeEqualw('${nowTime}','${oldTime}') 出来的是字符串就加上引号嘛,这都不会
      

  4.   

    getTimeEqualw('${nowTime}','${oldTime}')   出来的是字符串就加上引号嘛,这都不会你懂吗???
      

  5.   

    6楼的大哥,要是这么简单我还能来发贴吗?import java.text.ParseException;
    import java.text.SimpleDateFormat;
    import java.util.Date;public class TimeEquals {
    // 返回二个时是差的分钟数
    public static long getCompareDate(String startDate,Object endDate) throws ParseException { 
    SimpleDateFormat formatter=new SimpleDateFormat("yyyy-MM-dd k:mm:ss");
    Date dateFirst=formatter.parse(startDate);
    Date dateSecond=formatter.parse(endDate.toString());
    long l = dateSecond.getTime() - dateFirst.getTime();

    long day=l/(24*60*60*1000); //天数
    long hour=(l/(60*60*1000)-day*24); //小时数
    long min=((l/(60*1000))-day*24*60-hour*60); // 分钟数
    //long s=(l/1000-day*24*60*60-hour*60*60-min*60);
    return day + hour + min;

    }
    // 返回当前日期 时间
    public static String getNowDate(){
    String nowDate;
    SimpleDateFormat bartDateFormat = new SimpleDateFormat("yyyy-MM-dd k:mm:ss"); 
    Date date = new Date(); 

    nowDate = bartDateFormat.format(date);

    return nowDate;
    }
    }这是这个方法