|
Struts example source code file (jsp_0.jsp)
The Struts jsp_0.jsp source code<% request.setAttribute("decorator", "none"); response.setHeader("Cache-Control","no-cache"); //HTTP 1.1 response.setHeader("Pragma","no-cache"); //HTTP 1.0 response.setDateHeader ("Expires", 0); //prevents caching at the proxy server %> <p> <b>String Attributes </p> <p> Some tag attributes are expected to be Strings in which case String literals can be passed as the value, like the <i>href attribute in the a tag. </p> <p> <i> <s:a href="http://struts.apache.org/" /> </i> </p> <p> If the value that you want to use in one of these string literal attributes is stored on the Value Stack, then the <i>%{#name} syntax (alternative syntax) needs to be used. Assuming there is a value with the name "url" stored on the stack: </p> <p> <i> <s:a href="%{#url}" /> </i> </p> <p> will create an anchor and use the value of "url" for the <i>href attribute. </p> <p> <b>Value Attributes </p> <p> Other attributes expect an object as their value(not an string literal). In these attributes you can specify the name of a variable stored on the Value Stack, and the tag will look it up and use it. Like the <i>value attribute in the property tag. Assuming there is an object stored on the Value Stack with the name "movie", then: </p> <p> <i> <s:property value="movie" /> </i> </p> <p> will print the value to the page. To pass an String literal to an attribute that expects a value use the <i>%{'string'} notation. </p> <p> If you don't remember if an attribute expects an string literal or a value, you can always use the <i>%{value} notation: </p> <p> <i> <s:a href="%{'http://struts.apache.org/'}" /> <br /> <s:property value="%{#movie}" /> </i> </p> <p> <a href="#" onclick="window.open('http://struts.apache.org/2.x/docs/tag-syntax.html')">[More details] </p> Other Struts examples (source code examples)Here is a short list of links related to this Struts jsp_0.jsp source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.