I am new to Struts.I provide a model courseBean to the views to capture information.
It works perfectly if I input correct information with the correct form. Otherwise, if I input with the wrong format, it will throw exception.
Say, I entered abcd
in the courseBean.startDate
, it will throw exception because abcd
cannot be changed into Date
format.
Is there any ways to prevent those exception? Or Should I make a new Bean Class and set all the attributes of that class to be String?
<!--Title-->
<div class="control-group">
<label class="control-label" for="inputEmail">Title:</label>
<div class="controls">
<input type="text" name="courseBean.title" placeholder="Title" value="<s:property value="courseBean.title" />"/>
</div>
</div>
<!--Start Date-->
<div class="control-group">
<label class="control-label" for="inputPassword">Start Date:</label>
<div class="controls">
<input type="text" readonly="readonly" name="courseBean.startdate" placeholder="Start Date" value="<s:property value="courseBean.startdate" />" />
</div>
</div>
This questions focus on the auto data format convention of the input to the Bean.
Such as WARNING: Error setting expression 'courseBean.fee' with value '[Ljava.lang.String;@1b40489'
when I input "" in the textfield which map to the courseBean.fee