Struts2 s:decorator sitemesh上的url未被替换
s:url标记在sitemesh中使用装饰程序时不会被替换为html代码。在下一个示例中,将正确解释 web.xml:Struts2 s:decorator sitemesh上的url未被替换,struts2,taglib,sitemesh,Struts2,Taglib,Sitemesh,s:url标记在sitemesh中使用装饰程序时不会被替换为html代码。在下一个示例中,将正确解释 web.xml: [...] <context-param> <param-name>contextConfigLocation</param-name> <param-value> WEB-INF/security-context.xml WEB-INF/ap
[...]
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
WEB-INF/security-context.xml
WEB-INF/applicationContext.xml
</param-value>
</context-param>
<filter>
<filter-name>sitemesh</filter-name>
<filter-class>com.opensymphony.sitemesh.webapp.SiteMeshFilter</filter-class>
</filter>
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter>
<filter-name>struts-cleanup</filter-name>
<filter-class>org.apache.struts2.dispatcher.ActionContextCleanUp</filter-class>
</filter>
<filter-mapping>
<filter-name>sitemesh</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<welcome-file-list>
<welcome-file>login.jsp</welcome-file>
</welcome-file-list>
[...]
</web-app>
[…]
上下文配置位置
WEB-INF/security-context.xml
WEB-INF/applicationContext.xml
网站
com.opensymphony.sitemesh.webapp.SiteMeshFilter
springSecurityFilterChain
org.springframework.web.filter.DelegatingFilterProxy
支柱2
org.apache.struts2.dispatcher.ng.filter.strutspreadexecutefilter
struts清理
org.apache.struts2.dispatcher.ActionContextCleanUp
网站
/*
springSecurityFilterChain
/*
支柱2
/*
org.springframework.web.context.ContextLoaderListener
login.jsp
[...]
Login.jsp:
<%@ page language="java" contentType="text/html; charset=ISO-8859-15" pageEncoding="ISO-8859-15"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
**<link rel="stylesheet" type="text/css" href="<s:url value="/style/global.css" />" />**
[...]
****
[...]
Layout.jsp:(我的sitemesh装饰器)
****
[...]
结果HTML:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Café Mirabeau</title>
**<link rel="stylesheet" type="text/css" href="<s:url value='/style/global.css' />"** />
</head>
<body>
<h1>Header</h1>
<p><b>Navigation</b></p>
<hr />
**<link rel="stylesheet" type="text/css" href="/(myapp)/style/global.css" />**
米拉博咖啡馆
**
标题
导航
****
如您所见,login.jsp和layout.jsp上的行相同,但只有login.jsp上的行被正确替换
有人知道会发生什么吗?尝试放置struts2过滤器:
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
支柱2
/*
在sitemesh过滤器之前
<filter-mapping>
<filter-name>sitemesh</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
网站
/*
在您的
web.xml
中,它工作得非常好!谢谢我想,顺序是由过滤器详细说明的,而不是过滤器映射,它只是向后的!
<filter-mapping>
<filter-name>sitemesh</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>