在actionServlet中System.out.println(request.getParameter("drugCode"));看一看取没取到值。

解决方案 »

  1.   

    应该是:<html:form action="/BscInfoAction" method="POST">
      

  2.   

    换成<html:form action="/BscInfoAction" method="POST">也没用
      

  3.   

    那么有对应的actionForm对象么?从那里取值呢?
      

  4.   

    怎么取?我先要在JSP页面上输入要添加的值,然后由Action获得值,不能直接用Form里的Get方法的吧
      

  5.   

    创建一个继承自ActionForm的BscInfoForm,如:
    /*
     * @(#)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类里面取
      

  6.   

    BscInfoForm form=(BscInfoForm)actionForm;
    sql = "insert into sys_drug(drug_code)" +
            "values('" + form.getDrugCode() +"')";
      

  7.   

    <html:text property="drugCode" size="20"/>
    改成用标准的html试试
    <input type="text" name="drugCode" size="20">
      

  8.   

    现在的问题不是不执行INSERT语句,而是不能从JSP页面获得输入的值
      

  9.   

    试试这个方法 String flag=(String) PropertyUtils.getSimpleProperty(form, "flag");
      

  10.   

    import org.apache.commons.beanutils.PropertyUtils;
    试试这个方法 String flag=(String) PropertyUtils.getSimpleProperty(form, "flag");或到from bean中去取
      

  11.   

    struts没配对,不可能吧,这样都得不到数据
      

  12.   

    我总算知道为什么不能从页面上取值了,原来是确认按钮的愿意,不能通过<a href="...">来取值,只能用<html:submit property="submit" value="...">来取,谢谢各位了^_^