Struts 2 <s:head> example
The <s:head /> tag should be placed in the headsection of the HTML page. The s:head tag automatically generates links to the css and javascript libraries that are necessary to render the form elements.
This tag is used to output the HTML head information like encoding, CSS or JavaScript file. See the following snippet
** UPDATE: Struts 2 Complete tutorial now available here.
<%@ taglib prefix="s" uri="/struts-tags" %> <html> <head> <s:head /> </head>
Here Since no theame is provided in <s:head> tag ,it uses the default xhtml theme, it will render the output according to the template\xhtml\head.ftl file as shown below
<html> <head> <link rel="stylesheet" href="/your_project/struts/xhtml/styles.css" type="text/css"/> <script src="/your_project/struts/utils.js" type="text/javascript"></script> </head>
To include your own user defiend js or css file, just add it into the template\xhtml\head.ftl template file, and output it via <s:head>tag
The tag also includes the option to set a custom datepicker theme if needed.
<head> <title>My page</title> <s:head theme="ajax" calendarcss="calendar-green"/> </head>
If you use the ajax theme you can turn a debug flag by setting the debug parameter to true.
<head> <title>My page</title> <s:head theme="ajax" debug="true"/> </head>