如何从形式接收值?形式

2023-09-10 18:33:57 作者:┏一生只愿娶你〆

你好我怎样才能收到表格的值在我的JSP页面?该怎么办 ?在JSP有,一旦用户点击提交的表单中的值应该被发送到java类,但Java类没有收到价值的一种形式。 JSP的属性小写(值)和Java类的变量是大写。 (值)

Hi How can I receive a value from the form on my JSP page? what to do ? the JSP has a form once the user click on submit the values of form should be sent to java class but the java class does not receive the values. the attribute of JSP is lowercase (value) and the variable of Java class is upper case. (Value)

   <div id="Myform">
     <s:form action="inputs">
         <s:textfield name="value" label="input:"/>
         <s:submit/>
     </s:form>
   </div>

   <sx:div>
      <div id="Values">
        <div id="Value">Value is:${myClass.value}</div>
        <s:form action="SubmitValue" >
          <s:submit/>  //When I click on this one, it does not send the value to class
        </s:form>
  </sx:div>


  private String value;

  public void Values(){
    System.out.println("Value" + this.value);
  }

我已经生成使用Eclipse的getter和setter方法​​。

I have generated the getter and setters using Eclipse.

推荐答案

您需要提交的东西从你形成有东西在你的行动。看看 http://www.w3schools.com/html/html_forms.asp 。

You have to submit something from you form to have something in your action. Have a look http://www.w3schools.com/html/html_forms.asp.

如果您有属性名称动作键,这个属性被设置了一些值,如斯密特然后在jsp中可以使用&LT; S:房地产/&GT; 标签来显示该值,并隐藏字段提交此值回的动作。

If you have action with property name and this property is set with some value e.g. Smit then, in jsp you can use <s:property/> tag to display this value and hidden field to submit this value back to the action.

<sx:div>
  <div id="Values">
    <div id="Value">Value is:<s:property value="name"/></div>
    <s:form action="SubmitValue" >
      <s:hidden name="name"/>
      <s:submit/>  //When I click on this one, it does not send the value to class
    </s:form>
</sx:div>