Java 让sitemesh使用struts2
我试图将sitemesh集成到我的struts2应用程序中,但我发现它没有任何区别,也没有在日志中显示任何错误(或任何与sitemesh相关的内容) 我一开始只关注sitemesh站点上的所有文档,但运气不好,所以现在我尝试复制sitemesh示例下载中所做的工作,但毫无效果。任何想法都很好 web inf/web.xml:Java 让sitemesh使用struts2,java,struts2,sitemesh,Java,Struts2,Sitemesh,我试图将sitemesh集成到我的struts2应用程序中,但我发现它没有任何区别,也没有在日志中显示任何错误(或任何与sitemesh相关的内容) 我一开始只关注sitemesh站点上的所有文档,但运气不好,所以现在我尝试复制sitemesh示例下载中所做的工作,但毫无效果。任何想法都很好 web inf/web.xml: <?xml version="1.0" encoding="UTF-8"?> <web-app id="WebApp_ID" version="2.4"
<?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>
decorators/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>
我的网站-
()
谢谢大家我唯一看到的就是这里:
<?xml version="1.0" encoding="UTF-8"?>
<decorators defaultdir="/decorators">
<decorator name="main" page="main.jsp">
<pattern>/*</pattern>
</decorator>
</decorators>
/*
您需要一个/*而不仅仅是一个*作为模式
也许可以检查decorators目录的位置。它在应用程序的根目录中吗
我也有这个在我的设置,我不知道它是否有区别或没有
<filter-mapping>
<filter-name>sitemesh</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>INCLUDE</dispatcher>
</filter-mapping>
网站
/*
要求
向前地
包括
您能提供目录结构吗?非常感谢您的建议,第一个没有帮助,但第二个有帮助!万分感谢!
<?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>