Ex: <s:textfield name="empname" value="PPP"/> This line in JSP will
throw TLD exception.
While with HTML it works fine.
Ex:<input type="text" name="empname" value="PPP" />
Those are two entirely different tags. W3schools has a good summary of legal
attributes for HTML tags. The Struts project documents the legal attributes
for their tags. The documentation will make it clear.
Re: your subject line. What is a "Stuct"? I guess "Struct" initially, now I
see you're discussing "Struts", and it occurs to me you might have meant
"Stuck", but it isn't clear if any of those or something else were meant.
--
Lew
Weird because according to docs then textfield does have
a value attribute.
http://struts.apache.org/2.0.12/docs/textfield.html
What is the exact exception you get?
> While with HTML it works fine.
>
> Ex:<input type="text" name="empname" value="PPP" />
That is not relevant.
Arne
Such a line is fine.
Since you're getting a Tag Library Definition error...
You do have this line at the top of your JSP:
<%@taglib prefix="s" uri="/struts-tags" %>
and you do have the required struts Jar's on the class path,
namely: struts-taglib-x.y.z.jar where x y z are version numbers
for the version you're using?
Anyways this is something to consider later, strings in
struts 2 tags are evaluated as OGNL expressions...
so it might be clearer to write:
value="%{'PPP'}" if you mean the string PPP rather than
having it look for a property called PPP on the value stack
first... although this will not cause a TLD exception,
it simply might produce the wrong result.
Also there isn't anything wrong with using the HTML tag with struts 2.
Sometimes it's more convenient.
The <s:textfield> tag simply creates an html <textfield> tag...
By switching the Struts 2 theme to AJAX you can get simple
AJAX support as it will render the page with the required JavaScript
(there are other modes)...
mind you this is only for simple things... There really is no
requirement
to use struts UI tags in order to use Struts 2 actions.
So go ahead and use: <input type="text" name="empname" value="PPP" />
if you want.
The action tied to the submit button will have the setter: setEmpname
called
and will have the value of the text field passed in.