public void setDrugCode(String text) { this.drugCode= text.trim(); } /** * Reset all properties to their default values. * * @param mapping The mapping used to select this instance * @param request The servlet request we are processing */ public void reset(ActionMapping mapping, HttpServletRequest request) {
} /** * Validate the properties that have been set from this HTTP request, * and return an <code>ActionErrors</code> object that encapsulates any * validation errors that have been found. If no errors are found, return * <code>null</code> or an <code>ActionErrors</code> object with no * recorded error messages. * * @param mapping The mapping used to select this instance * @param request The servlet request we are processing */ private ActionErrors errors; public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { errors = new ActionErrors(); String submit = request.getParameter("submit"); // front end validation when save is clicked. if (submit != null) { /*"!!!这里应该进行参数合法性检查,忽略!"*/ } return errors; } }----------- 然后在struts-config.xml里面做好相应的配置,当 jsp提交的时候,数据会自动添入drugCode 字段,然后在action类里面取
/*
* @(#)shortmessageCreateForm.java 1.0 2002/12/12
*
*/
package com;/**
* @description 设置和得到登录页面的信息。
*
*/
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;import javax.servlet.http.HttpServletRequest;
import java.util.Calendar;
import java.util.GregorianCalendar;public final class LoginForm extends ActionForm {
/* 继承struts的ActionForm类. */
String drugCode= "";
/**
* 定义所有变量的set、get方法
*
*/
public String getDrugCode() {
return drugCode;
}
public void setDrugCode(String text) {
this.drugCode= text.trim();
}
/**
* Reset all properties to their default values.
*
* @param mapping The mapping used to select this instance
* @param request The servlet request we are processing
*/
public void reset(ActionMapping mapping, HttpServletRequest request) {
}
/**
* Validate the properties that have been set from this HTTP request,
* and return an <code>ActionErrors</code> object that encapsulates any
* validation errors that have been found. If no errors are found, return
* <code>null</code> or an <code>ActionErrors</code> object with no
* recorded error messages.
*
* @param mapping The mapping used to select this instance
* @param request The servlet request we are processing
*/ private ActionErrors errors; public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request) { errors = new ActionErrors(); String submit = request.getParameter("submit"); // front end validation when save is clicked.
if (submit != null) {
/*"!!!这里应该进行参数合法性检查,忽略!"*/
} return errors;
}
}-----------
然后在struts-config.xml里面做好相应的配置,当 jsp提交的时候,数据会自动添入drugCode 字段,然后在action类里面取
sql = "insert into sys_drug(drug_code)" +
"values('" + form.getDrugCode() +"')";
改成用标准的html试试
<input type="text" name="drugCode" size="20">
试试这个方法 String flag=(String) PropertyUtils.getSimpleProperty(form, "flag");或到from bean中去取