s:url未在装饰器sitemesh上替换 [英] s:url not replaced on decorator sitemesh

查看:238
本文介绍了s:url未在装饰器sitemesh上替换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

s:url标记替换为html代码.在下一个示例中将正确解释.

s:url tags are not being replaced to html code when using a decorator with sitemesh. In the next example will be correctly explained.

web.xml:

[...]
    <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>

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 :(我的站点网格装饰器)

Layout.jsp: (my sitemesh decorator)

<%@ page language="java" contentType="text/html; charset=ISO-8859-15" pageEncoding="ISO-8859-15"%>
<%@ taglib prefix="decorator" uri="http://www.opensymphony.com/sitemesh/decorator" %>
<%@ taglib prefix="page" uri="http://www.opensymphony.com/sitemesh/page" %>
<%@taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!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-15">

        **<link rel="stylesheet" type="text/css" href="<s:url value="/style/global.css" />" />**

    </head>
[...]

结果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上的行.

As you can see, the same line is on the login.jsp and on layout.jsp, but only on login.jsp is correctly replaced.

有人知道会发生什么吗?

Anyone knows what can be happening?

推荐答案

尝试放置您的struts2过滤器:

Try putting your struts2 filter:

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

sitemesh过滤器之前

before the sitemesh filter

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

在您的web.xml中.

这篇关于s:url未在装饰器sitemesh上替换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆