我如何设置Action类的值 [英] how I can set value of from Action class

查看:77
本文介绍了我如何设置Action类的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个jsp struts文件,含



I have a jsp struts file with

<html:select styleId="selectedop" property="selectedop" onchange="javascript:submitit();" value="select">
     <html:option value="--select--">--select--</html:option>
     <%
          try {
               //to connect need wifi (since public ip)
               //String url = "jdbc:mysql://dbno2.ce6zvdgnoq7r.ap-southeast-2.rds.amazonaws.com:3306/INVENTRY?user=aghil&password=password1";
               String url = connectionString;
               Class.forName("com.mysql.jdbc.Driver");
               Connection con = DriverManager.getConnection(url);
               ResultSet rs;
               PreparedStatement pst = con.prepareStatement(selectQuery);
               rs = pst.executeQuery();
               while (rs.next()) {
                    String name = rs.getString(1);
     %>
     <html:option value="<%=name%>"><%=name%></html:option>
     <%
          }%>
     <%
          } catch (Exception e) {
               out.print(e);
          }
     %>
</html:select>





其ActionForm类包含



its ActionForm class contains

private String selectedop;



及其getter和setter方法。



问题是在提交重新加载jsp页面之后,在selectedop中选择的值更改为其第一个值。



但我希望它像以前一样设置。

所以我设置它在Action类中的值在ActionForm类中使用它的setter方法。

但它没有用。

那我怎么设置html的值:select from Action class


and its getter and setter methods.

problem is after submitting reloading jsp page, the value selected in "selectedop" change to its first value.

But I want it to as set as previous.
So I set its value in its Action class using its setter method in ActionForm class.
But it did not worked.
So how I can set value of html:select from Action class

推荐答案

您好,



请删除属性 html:选择标签。



问候,
Hello,

Please remove value attribute on html:select tag.

Regards,


这篇关于我如何设置Action类的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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