首先,当然是需要你先对struts有一定的了解:)
1. 定义相应页面(client.jsp)的form bean,这里假设为ClientForm;注意在struts_config.xml中定义映射关系;client.jsp中包含了你需要的html form内容,比如一个select下拉框;
这里是form bean的代码(其实就是一个java bean,继承了ActionForm,然后需要重载reset和validate方法):
-----------------------------------------------
package com.egi.core.ioblock.form;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
/**
*Copyright: Copyright (c) 2002</p> <p>
*@author sjoy
*@created2003年6月4日
*@version1.0
*/
public class LoginForm extends ActionForm {
//-----------------------------Instance Variable
private String appName = null;
private String type = null;
public String getAppName() {
return appName;
}
public void setAppName(String appName) {
this.appName = appName;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public void reset(ActionMapping mapping, HttpServletRequest request) {
appName = null;
type = null;
}
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
ActionErrors errors = new ActionErrors();
if (appName == null (北联网教程,专业提供视频软件下载)
……