如何从形式接收值? [英] How to receive values from a form?

查看:84
本文介绍了如何从形式接收值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好我怎样才能收到表格的值在我的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>

这篇关于如何从形式接收值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆