应该是:<html:radio property="2" value="2" />
即property=value

解决方案 »

  1.   

    那么property和value岂不是有关联?这样对于value来讲,有好大的局限性。
      

  2.   

    这个是Radio taglib的源码:package org.apache.struts.taglib;
    import java.io.IOException;
    import java.lang.reflect.InvocationTargetException;
    import javax.servlet.jsp.JspException;
    import javax.servlet.jsp.PageContext;
    import javax.servlet.jsp.JspWriter;
    import org.apache.struts.util.BeanUtils;
    import org.apache.struts.util.MessageResources;
    /**
     * Tag for input fields of type "radio".
     *
     * @author Craig R. McClanahan
     * @version $Revision: 1.11 $ $Date: 2001/05/20 01:19:06 $
     */public final class RadioTag extends BaseHandlerTag {
        // ----------------------------------------------------- Instance Variables
        /**
         * The message resources for this package.
         */
        protected static MessageResources messages =
    MessageResources.getMessageResources
    ("org.apache.struts.taglib.LocalStrings");
        /**
         * The name of the bean containing our underlying property.
         */
        private String name = Constants.BEAN_KEY;    public String getName() {
    return (this.name);
        }    public void setName(String name) {
    this.name = name;
        }
        /**
         * The property name for this field.
         */
        private String property = null;
        /**
         * The server value for this option.
         */
        private String value = null;
        // ------------------------------------------------------------- Properties
        /**
         * Return the property name.
         */
        public String getProperty() { return (this.property);    }
        /**
         * Set the property name.
         *
         * @param name The new property name
         */
        public void setProperty(String property) { this.property = property;    }
        /**
         * Return the server value.
         */
        public String getValue() { return (this.value);    }
        /**
         * Set the server value.
         *
         * @param value The new server value
         */
        public void setValue(String value) { this.value = value;    }
      

  3.   

        // --------------------------------------------------------- Public Methods
        /**
         * Generate the required input tag.
         *
         * @exception JspException if a JSP exception has occurred
         */
        public int doStartTag() throws JspException { // Acquire the current value of the appropriate field
    Object current = null;
    Object bean = pageContext.findAttribute(name);
    if (bean == null)
        throw new JspException
            (messages.getMessage("getter.bean", name));
    try {
        current = BeanUtils.getSimpleProperty(bean, property);
        if (current == null)
            current = "";
        } catch (IllegalAccessException e) {
    throw new JspException
        (messages.getMessage("getter.access", property, name));
        } catch (InvocationTargetException e) {
    Throwable t = e.getTargetException();
    throw new JspException
        (messages.getMessage("getter.result",
     property, t.toString()));
    } catch (NoSuchMethodException e) {
        throw new JspException
            (messages.getMessage("getter.method", property, name));
    } // Create an appropriate "input" element based on our parameters
    StringBuffer results = new StringBuffer("<input type=\"radio\"");
    results.append(" name=\"");
    results.append(this.property);
    results.append("\"");
    if (accessKey != null) {
        results.append(" accesskey=\"");
        results.append(accessKey);
        results.append("\"");
    }
    if (tabIndex != null) {
        results.append(" tabindex=\"");
        results.append(tabIndex);
        results.append("\"");
    }
    results.append(" value=\"");
    results.append(this.value);
    results.append("\"");
    if (value.equals(current))
        results.append(" checked");
    results.append(prepareEventHandlers());
    results.append(prepareStyles());
    results.append(">"); // Print this field to our output writer
    JspWriter writer = pageContext.getOut();
    try {
        writer.print(results.toString());
    } catch (IOException e) {
        throw new JspException
    (messages.getMessage("common.io", e.toString()));
    } // Continue processing this page
    return (EVAL_BODY_TAG);    }
        /**
         * Optionally render the associated label from the body content.
         *
         * @exception JspException if a JSP exception has occurred
         */
        public int doEndTag() throws JspException { if (bodyContent == null)
        return (EVAL_PAGE); JspWriter writer = pageContext.getOut();
    try {
        writer.println(bodyContent.getString().trim());
    } catch (IOException e) {
        throw new JspException
    (messages.getMessage("common.io", e.toString()));
    } // Continue evaluating this page
    return (EVAL_PAGE);    }
        /**
         * Release any acquired resources.
         */
        public void release() { super.release();
    name = Constants.BEAN_KEY;
    property = null;
    value = null;    }
    }
      

  4.   

    是的,据此也不能推出property=value.我在研究strut-html.tld这个文件,也行可以找出来,但好像感觉都不行。
      

  5.   

    bean里面的值和value相同,则会自动显示checked了
      

  6.   

    问题我刚才已经解决了,方法同nc201(Bricklayer),但我不知道这样做会不会有什么副作用?非常感谢nc201(Bricklayer)的热心帮助。