Struts2标签给出了jasper异常

时间:2012-08-04 20:03:13

标签: java struts2 ognl

以下是jsp代码

<ul class="nav pull-right">
          <s:if test="%{curUser != null}">
              <li class="dropdown">
                <a href="javascript:void(0)" class="dropdown-toggle" data-toggle="dropdown">%{curUser.userName}<b class="caret"></b></a>
                <ul class="dropdown-menu">
                  <s:if test="%{curUser.admin eq true}">
                    <li><a href="/admin" title="Admin Section"><i class="icon-certificate"></i> Admin</a></li>
                  </s:if>
                  <li><a href="/user/%{curUser.userName}" title="%{curUser.userName}'s Profile"><i class="icon-user"></i> Profile</a></li>
                  <li><a href="/user/profile.html?action=edit"><i class="icon-cog"></i> Edit Profile</a></li>
                  <li><a href="/login.html?action=logout"><i class="icon-off"></i> Sign out</a></li>
                </ul>
              </li>
            </s:if>
            <s:else>
              <li><a href="/login">Login</a></li>
              <li class="divider-vertical"></li>
              <li><a href="/signup">Sign Up</a></li>
            </s:else>
        </ul>

我收到此错误。需要帮助。

org.apache.jasper.JasperException: An exception occurred processing JSP page /decorators/base.jsp at line 45

42:               </a></li>
43:             </ul>
44:             <ul class="nav pull-right">
45:               <s:if test="%{curUser != null}">
46:                   <li class="dropdown">
47:                     <a href="javascript:void(0)" class="dropdown-toggle" data-toggle="dropdown">%{curUser.userName}<b class="caret"></b></a>
48:                     <ul class="dropdown-menu">

这是我的web.xml配置 - 我想问题是使用带有sitemesh的Struts标签。

   <filter>
    <filter-name>sitemesh</filter-name>
    <filter-class>com.opensymphony.sitemesh.webapp.SiteMeshFilter</filter-class>
  </filter>
  <filter-mapping>
    <filter-name>sitemesh</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>

  <filter>
    <filter-name>LoginCheckFilter</filter-name>
    <filter-class>com.tutorial.filter.LoginCheckFilter</filter-class>
  </filter>
  <filter-mapping>
    <filter-name>LoginCheckFilter</filter-name>
    <url-pattern>/admin</url-pattern>
    <url-pattern>/admin/*</url-pattern>
  </filter-mapping>

  <filter>
    <filter-name>UrlRewriteFilter</filter-name>
    <filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
    <init-param>
      <param-name>logLevel</param-name>
      <param-value>WARN</param-value>
    </init-param>
  </filter>
  <filter-mapping>
    <filter-name>UrlRewriteFilter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>

  <filter>
    <filter-name>struts2</filter-name>
    <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
    <init-param>
      <param-name>actionPackages</param-name>
      <param-value>com.tutorial.action</param-value>
    </init-param>
  </filter>
  <filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>FORWARD</dispatcher>
  </filter-mapping>

  <listener>
    <listener-class>
      org.springframework.web.context.ContextLoaderListener
    </listener-class>
  </listener>

  <listener>
    <listener-class>org.apache.struts2.dispatcher.ng.listener.StrutsListener</listener-class>
  </listener>

1 个答案:

答案 0 :(得分:0)

对我来说发生了同样的事情,触摸我也收到了另一个错误。 会发生什么是struts标签在运行时没有被替换,所以它不能由html处理器编译。 解决方案是在web.xml中,struts过滤器映射必须高于sitemesh过滤器映射。

我在这个主题中也回答了同样的问题: s:url not replaced on decorator sitemesh

看看你听起来是否熟悉。