The <s:head> tag is used to output the HTML head information like encoding, CSS or JavaScript file. See the following snippet :

<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
<s:head />
</head>
<body>
..

Assume you are using the default xhtml theme, it will render the output according to the “template\xhtml\head.ftl” file

<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>
<body>
..

To include your new js or css file, just add it into the “template\xhtml\head.ftl” template file, and output it via <s:head> tag.

Actually, this <s:head> tag is not require to put on top and warp by HTML <head> tag, e.g

<head>
<s:head />
</head>

You can put it in anywhere, it just output the CSS and js file path (default in xhtml theme).

<head>
</head>
<body>
<s:head />
...
Good Practice

To improve the website performance, the good practice is always put CSS file on top of the page; while the js file on bottom of the page. So, the <s:head> tag may not suitable, a good practice should be create new tag to output the CSS and js file separately, e.g <s:css> and <s:javascript>.

Reference

  1. Struts 2 <s:head> example
Any Java questions or problems? please post at this JavaNullPointer.com forum, see you there ~
[ Read More ] You can find more similar articles at Struts 2.x Tutorials