こんにちは、Tapestry 5 を使用して計画 Web アプリケーションを作成し、春のセキュリティ問題を回避するために、org.apache.tapestry5.TapestryFilter の URL パターンを /* から /planning/* に変更しました。 Java / .tml ファイルに応じて、Web アプリケーションはそのまま動作しますが、CSS スタイルシートが取得されなくなりました。
コンポーネント ファイルに Layout.java があり、対応する Layout.tml があります。次に、webapp ファイル (WEB-INF の外側) のレイアウト フォルダーに layout.css ファイルがあります
。 スタイルシートは Layout.java ファイルで呼び出されています。 by @Import(stylesheet="context:layout/layout.css") - これは以前は常に機能していました!
CSSファイルをplanning/layout/layout.cssサブディレクトリに移動しようとしましたが、それでも違いはないようです!
Web.xml
<display-name>Planning Tapestry 5 Application</display-name>
<context-param>
<param-name>tapestry.app-package</param-name>
<param-value>com.quartetfs.planning.tapestry</param-value>
</context-param>
<filter>
<filter-name>app</filter-name>
<filter-class>org.apache.tapestry5.TapestryFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>app</filter-name>
<url-pattern>/planning/*</url-pattern>
</filter-mapping>
Layout.java
import org.apache.tapestry5.*;
import org.apache.tapestry5.annotations.*;
import org.apache.tapestry5.ioc.annotations.*;
import org.apache.tapestry5.BindingConstants;
/**
* Layout component for pages of Planning Application.
*/
@Import(stylesheet="context:layout/layout.css")
public class Layout
{
/** The page title, for the <title> element and the <h1> element. */
@Property
@Parameter(required = true, defaultPrefix = BindingConstants.LITERAL)
private String title;
@Property
private String pageName;
@Property
@Parameter(defaultPrefix = BindingConstants.LITERAL)
private String sidebarTitle;
@Property
@Parameter(defaultPrefix = BindingConstants.LITERAL)
private Block sidebar;
@Inject
private ComponentResources resources;
public String getClassForPageName()
{
return resources.getPageName().equalsIgnoreCase(pageName)
? "current_page_item"
: null;
}
public String[] getPageNames()
{
return new String[] { "planning/Index", };// "About", "Contact" }; TODO
}
}
レイアウト.tml
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1- strict.dtd">
<!--
Design by Free CSS Templates
http://www.freecsstemplates.org
Released for free under a Creative Commons Attribution 2.5 License
Title : Concrete
Version : 1.0
Released : 20080825
Description: A Web 2.0 design with fluid width suitable for blogs and small websites.
-->
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd"
xmlns:p="tapestry:parameter">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>${title}</title>
</head>
<body>
<!-- start header -->
<div id="header">
<div id="logo">
<h1>
<t:pagelink page="planning/index">Project and Resource Planning</t:pagelink>
</h1>
</div>
<div id="menu">
<ul>
<li t:type="loop" source="pageNames" value="pageName" class="prop:classForPageName">
<t:pagelink page="prop:pageName">${pageName}</t:pagelink>
</li>
</ul>
</div>
</div>
<!-- end header -->
<!-- start page -->
<div id="page">
<!-- start sidebar -->
<div id="sidebar">
<ul>
<li id="search" style="background: none;">
</li>
<li t:type="if" test="sidebar">
<h2>${sidebarTitle}</h2>
<div class="sidebar-content">
<t:delegate to="sidebar"/>
</div>
</li>
</ul>
</div>
<!-- end sidebar -->
<!-- start content -->
<div id="content">
<div class="post">
<div class="title">
<h2>${title}</h2>
</div>
<div class="entry">
<t:body/>
</div>
</div>
</div>
<!-- end content -->
<br style="clear: both;"/>
</div>
<!-- end page -->
<!-- start footer -->
<div id="footer">
<p class="legal">
©2009 com.example. All Rights Reserved.
•
Design by
<a href="http://www.freecsstemplates.org/">Free CSS Templates</a>
•
Icons by
<a href="http://famfamfam.com/">FAMFAMFAM</a>.
</p>
</div>
<!-- end footer -->
</body>
</html>