我想用 Struts 在 JSP 中创建组合框。我的 JSP 页面是:
<s:form id="form-sign-up" class="round styled" action="signUp" method="post" name="myForm" theme="xhtml" enctype="multipart/form-data">
<label>Email:</label><input type="text" class="keyup-email text-input" name="7" value="" />
<br />
<br />
<s:textfield name="fname" size="40" maxlength="40" required="true" key="your.FName-label"/>
<s:textfield name="lname" size="40" maxlength="40" required="true" key="your.LName-label"/>
<br />
<s:set var="gender" value="{'male','female'}" />
<s:select label="gender" name="gender"
accesskey="" headerKey="-1" headerValue="I'm..."
cssClass="" list="gender"/>
<br />
<s:password name="Pass" size="40" maxlength="40" required="true" key="your.Pass-label"/>
<s:textarea name="job" label="Job" id="job" cols="32" rows="3" />
<s:submit value="Submit" id="btn-submit" align="left"/>
</s:form>
现在在我的行动中,我有:
public class SignUpAction extends ActionSupport {
private String fname;
private String lname;
private String gender;
private String email;
private String pass;
private String job;
public static DataBase db ;
@Override
public void validate(){
}
@Override
public String execute() throws Exception {
DataBase db = new DataBase();
try {
User u1 = new User(fname,lname,gender,email,pass,job);
db.Add_User(u1);
} catch ( HibernateException e ) {
e.printStackTrace();
}
return SUCCESS;
}
... Getters and setters ...
}
我想获取性别的值并将其值保存在我的数据库中,但我无法<s:select...
从 JSP 中获取值。