1

サイトメッシュを struts2 アプリに統合しようとしていますが、違いはなく、ログにエラー (またはサイトメッシュに関連するもの) がまったく表示されないことがわかりました。

sitemesh サイトのすべてのドキュメントに従うことから始めましたが、運がなかったので、sitemesh-example のダウンロードで行われたことをコピーしようとしましたが、役に立ちませんでした。どんなアイデアでも素晴らしいでしょう。

web-inf/web.xml:

<?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/decorators.xml:

<?xml version="1.0" encoding="UTF-8"?>
<decorators defaultdir="/decorators">
    <decorator name="main" page="main.jsp">
          <pattern>*</pattern>
    </decorator>
</decorators> 

web-inf/lib フォルダー:

sitemesh-2.4.2.jar
sitemesh-decorator.tld
sitemesh-page.tld

デコレータ/main.jsp:

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

みんなありがとう

4

1 に答える 1

3

私が見ている唯一のものはここにあります:

 <?xml version="1.0" encoding="UTF-8"?>
 <decorators defaultdir="/decorators">
  <decorator name="main" page="main.jsp">
      <pattern>/*</pattern>
  </decorator>
 </decorators>

パターンとして * だけでなく /* が必要です。

デコレータディレクトリの場所を確認してください。アプリのルートにありますか?

私もセットアップにこれを持っていますが、それが違いを生むかどうかはわかりません。

  <filter-mapping>
    <filter-name>sitemesh</filter-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>FORWARD</dispatcher>
    <dispatcher>INCLUDE</dispatcher>
  </filter-mapping>
于 2009-11-24T02:35:01.093 に答える