简体   繁体   中英

How to use a global forward (struts-config.xml) in Struts2 JSP?

I am migrating a Struts1 web app to Struts2. I have the following in my struts-config.xml file:

<global-forwards >
    <forward name="css" path="/common/css/app-global.css" />
</global-forwards>

In my JSP today (Struts 1), I have this call:

<link rel="stylesheet" id="default" type="text/css" href="<html:rewrite forward='css'/>" />

What is the equivalent way to do this in the JSP in Struts 2? I tried <s:url value="css"> but no luck.

I just want to point to the reference in global-forwards. I'm sure it's something simple I'm overlooking.

UPDATE: Listen, if there is a better way than using struts-config.xml (which I'm wondering if that should even be used in Struts 2), then by all means, set me straight. I just didn't know if using the actual path was superior/inferior to using the specified forward name.

No need for some global forward mapping or whatever. Just use <s:url> tag with value attribute.

<link rel="stylesheet" id="default" type="text/css" 
      href="<s:url value='/common/css/app-global.css'/>" />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM