jsp页面调用java类的问题。
首先 我有一个类ListSql 里面有 id、name、age 分别都有get和set方法。现在我的一个jsp页面是一个表单,代码属下
<form id="form1" name="form1" method="post" action="Listsql.jsp">
<%
ListSql listsql = new ListSql();
listsql.setId("id");
listsql.setName("name");
listsql.setAge("age");
listsql.setTable("table");
%>
表名
<input name="table" type="checkbox" id="table" value="table" />
<hr />
字段一
<input name="id" type="checkbox" id="id" value="id" />
字段二
<input name="name" type="checkbox" id="name" value="name" />
字段三
<input name="age" type="checkbox" id="age" value="age" />
<hr />
<input type="submit" name="button" id="button" value="提交" />
</form>
然后我想点击提交的时候,传给java类,然后从这个类中再获取出来显示到领一个jsp页面,代码如下:
<%
ListSql listsql = new ListSql();
String id = "";
String name = "";
String age = "";
String table = "";
//ID = request.getParameter(listsql.getId());
id = listsql.getId();
name = listsql.getName();
age = listsql.getAge()
table = listsql.getTable()
%>
<%=id %>、<%=name %>
但是ID 和 name 都不能输出 是为什么? 请高手解答一下。谢谢
搜索更多相关主题的帖子:
java 表单 action method
----------------解决方案--------------------------------------------------------
其实没有必要这样,你只要将类ListSql 导入到Listsql.jsp,具体如下
<form id="form1" name="form1" method="post" action="Listsql.jsp">
表名
<input name="table" type="checkbox" id="table" value="table" />
<hr />
字段一
<input name="id" type="checkbox" id="id" value="id" />
字段二
<input name="name" type="checkbox" id="name" value="name" />
字段三
<input name="age" type="checkbox" id="age" value="age" />
<hr />
<input type="submit" name="button" id="button" value="提交" />
</form>
然后我想点击提交的时候,传给java类,然后从这个类中再获取出来显示到领一个jsp页面,代码如下:
<%
ListSql listsql = new ListSql();
listsql.setId("id");
listsql.setName("name");
listsql.setAge("age");
listsql.setTable("table");
%>
<%
ListSql listsql = new ListSql();
String id = "";
String name = "";
String age = "";
String table = "";
//ID = request.getParameter(listsql.getId());
id = listsql.getId();
name = listsql.getName();
age = listsql.getAge()
table = listsql.getTable()
%>
<%=id %>、<%=name %>
----------------解决方案--------------------------------------------------------
调用类直接import
----------------解决方案--------------------------------------------------------
哦 明白了 直接把传过来的值进行set就可以了,需要的时候,get出来就Ok啦 谢谢上面的兄弟了。 自己脑筋不打弯了 呵呵!
----------------解决方案--------------------------------------------------------
呵呵,没有数据
----------------解决方案--------------------------------------------------------
还真厉害呢
----------------解决方案--------------------------------------------------------