What is the best way to crop this line / where is the best place to place the crop code?
Let's say I have the following text box in my jsp:
<s:textfield label="First Name" name="person.firstname"/>
Action class:
public class BaseAction extends ActionSupport implements ServletRequestAware, SessionAware { private Person person;
bean:
public class Person implements Serializable { private String lastname; private String firstname;
I can change the default setting in the bean, but this seems like a hack:
public void setFirstname(String firstname) { this.firstname = firstname.trim(); }
EDIT : I also saw this question: struts2 trim the entire line obtained from forms , where some also suggested that the “correct” method is to use an interceptor.
Why is the interceptor “correct”? What is changing the bean settings wrong?
java string design struts2
nmc
source share