Hello,
I'm following the Struts tutorial, and if I strictly follow the
tutorial "Processing forms"
https://struts.apache.org/getting-started/processing-forms, I use
Struts2-core 7.0.0 and Jetty maven plugin v11.0.25
The error happens because of that portion of the register.jsp code:
<s:form action="register">
<s:textfield name="personBean.firstName" label="First name" />
<s:textfield name="personBean.lastName" label="Last name" />
<s:textfield name="personBean.email" label ="Email"/>
<s:textfield name="personBean.age" label="Age" />
<s:submit/>
</s:form>
I start from index.jsp that contains a link <a href="register.jsp">Register</a>.
When I click on the link get a JasperException caused by the following one :
java.lang.NullPointerException: Cannot invoke
"java.util.List.add(Object)" because "tags" is null
So I checked out the struts-example official repo and saw that the
namespace attribute was specified
e.g if I instead write this
<s:form action="register" namespace="">
........ (fields)
</s:form>
For some reason it works. I've read the struts tag reference, and if
you don't specify the namespace it default to "current namespace".
The exception seems to only happens when I directly link to a jsp :
Let's say I have a foo.jsp containing the same form code, and in
index.jsp I add a link to an action FooAction that just returns
foo.jsp, then the form display properly.
So my guess is that JSP doesn't go through the mapping of struts.xml
and for some reasons using <s:form> without an attribute tag causes
this exception, but why ? I can't find a reason why and the tutorial
assumes the code shown is supposed to work, but it isn't.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]