Or you could simply use JSTL.
The following works for me:
<script type="text/javascript" src="<c:url value="/javascript/jquery/jquery-1.4.2.min.js"/>"></script>



/robert

----- Original Message ----- From: "Li Ying" <liying.cn.2...@gmail.com>
To: "Struts Users Mailing List" <user@struts.apache.org>
Sent: Thursday, October 14, 2010 10:33 AM
Subject: Re: referencing javascript files from (action) jsp file


I suggest you to reference your resource file(js, image, css and so
on) in this way:

<script type="text/javascript" src="<s:property value="contextPath"
/>/path/filename.js"></script>


The [<s:property value="contextPath" />] part will
render the contextPath where the web application
is deployed.

The [contextPath] is a property defined in Action:
public String getContextPath() {
return ServletActionContext.getServletContext().getContextPath();
}

I put this property in the supper class of all of the Action classes
so i can reference this property in all the pages

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org

Reply via email to