因要用s:if 等标签, 按教材在web.xml中定义了<taglib>以及<taglib-location>等, 配置应该是没问题的, 按教材填写的, 不使用if等标签就没问题, 一旦使用if标签, 就提示javax.servlet.ServletException: org.apache.jasper.JasperException: Unable to read TLD "META-INF/taglib.tld" from JAR file "file:/F:/Tomcat 6.0/webapps/coca/WEB-INF/lib/struts2-core-2.0.11.1.jar": java.lang.NullPointerException. 可是struts2-core-2.0.11.1.jar/META-INF/里面没有taglib.tld啊,只有struts-tags.tld, 应该怎么解决这个配置问题?

解决方案 »

  1.   

    在你的jsp文件头部加入:<%@ taglib prefix="s" uri="/struts-tags"%>
      

  2.   

    可以不需要在web.xml中配置<taglib>,直接在jsp中<%@ taglib prefix="s" uri="/struts-tags"%>
      

  3.   

    谢谢楼上两位啊, 我的JSP头部已经加了<%@ taglib prefix="s" uri="/struts-tags"%>, 平时只使用s:iterator标签的时候, 就没提示出错, 但当我使用
    <s:set name="age" />
    <s:if test="age > 6">
    大人
    </s:if>
    这种标签的时候,就出错了, 提示org.apache.jasper.JasperException: /case.jsp(72,3) According to TLD or attribute directive in tag file, attribute test does not accept any expressions如果在web.inf中配置好taglib的话, 就提示javax.servlet.ServletException: org.apache.jasper.JasperException: Unable to read TLD "META-INF/taglib.tld" from JAR file "file:/F:/Tomcat 6.0/webapps/coca/WEB-INF/lib/struts2-core-2.0.11.1.jar": java.lang.NullPointerException. 我使用的tomcat 6.0.1.4, struts2-core-2.0.11.1
      

  4.   

    <s:set name="month" value="1" />
    <s:if test="#month>0 && month<=3">
    第一季度
    </s:if>
    <s:else>
    输入错误
    </s:else>使用OGNL表达式#month, 一切正常, 输出结果为第一季度但改成EL表达式, <s:set name="month" value="1" />
    <s:if test="${month>0 && month<=3}">
    第一季度
    </s:if>
    <s:else>
    输入错误
    </s:else>就马上提示出错org.apache.jasper.JasperException: /case.jsp(72,3) According to TLD or attribute directive in tag file, attribute test does not accept any expressions 怎么解决?
      

  5.   

    找一个英文网站上找到答案, Struts2 compatibility issues - EL expressions disabled in 2.0.11
      

  6.   

    ognl与EL的关系是替代,而不是互补.
    strut2用ognl替代了原来的EL作为默认的页面el引擎, 直接在struts2里使用原el是不行的
    如果想使用原EL的话可以通过配置使用,方法网上有