首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >让sitemesh与struts2协同工作

让sitemesh与struts2协同工作
EN

Stack Overflow用户
提问于 2009-11-24 09:03:09
回答 1查看 3.9K关注 0票数 1

我正在尝试将sitemesh集成到我的struts2应用程序中,但我发现这没有任何区别,日志中也没有显示任何错误(或任何与sitemesh相关的信息)。

我已经开始遵循sitemesh站点上的所有文档,没有运气,所以现在我试图复制sitemesh-example下载中所做的事情,但无济于事。任何想法都是很棒的。

web-inf/web.xml:

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4"
  xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
  <display-name>Sample</display-name>

  <filter>
    <filter-name>struts2</filter-name>
    <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
  </filter>

  <filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>


  <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>

</web-app>

web-inf/decators.xml:

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8"?>
<decorators defaultdir="/decorators">
    <decorator name="main" page="main.jsp">
          <pattern>*</pattern>
    </decorator>
</decorators> 

web-inf/lib文件夹:

代码语言:javascript
复制
sitemesh-2.4.2.jar
sitemesh-decorator.tld
sitemesh-page.tld

装饰器/main.jsp:

代码语言:javascript
复制
<%@ taglib uri="http://www.opensymphony.com/sitemesh/decorator" prefix="decorator" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
 <title>
 My Site - <decorator:title default="Welcome!" />
 </title>
 <decorator:head />
</head>

 <body>
 <h1><decorator:title default="Welcome!" /></h1>
 <p><decorator:body /></p> 
 <p><small>
 (<a 
    href="?printable=true">printable version</a>)
    </small></p>
 </body>
</html>

谢谢你们

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2009-11-24 10:35:01

我唯一能看到的就是这里:

代码语言:javascript
复制
 <?xml version="1.0" encoding="UTF-8"?>
 <decorators defaultdir="/decorators">
  <decorator name="main" page="main.jsp">
      <pattern>/*</pattern>
  </decorator>
 </decorators>

您需要一个/*,而不仅仅是一个*作为模式。

也许可以检查一下装饰器目录的位置。它在应用程序的根目录中吗?

我在我的设置中也有这个,我不知道它是否有区别。

代码语言:javascript
复制
  <filter-mapping>
    <filter-name>sitemesh</filter-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>FORWARD</dispatcher>
    <dispatcher>INCLUDE</dispatcher>
  </filter-mapping>
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/1787164

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档