jsp页面往一个封装类传值问题 Attention.java代码: package com.netshop; import java.sql.*; import java.text.*; public class Attention extends executeWay { public long ID; public long userID; public long goodsID; public int tag; public Attention() { ID=0; userID=0; goodsID=0; tag=0; } public boolean add() { String strSql="insert into attention(userID,goodsID,tag)"; strSql=strSql+"values("; strSql=strSql+"'"+userID+"',"+"'"+goodsID+"',"+"'"+tag+"')"; System.out.println(strSql); boolean isAdd=super.exeSqlUpdate(strSql); return isAdd; } } query。jsp代码: <%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %> <%@ page import="com.netshop.*"%> <jsp:useBean scope="page" id="at" class="com.netshop.Attention"/> <% long userID=2; long goodsID=3; int tag=2; boolean isAdd=at.add(); if(isAdd){ out.println("good"); } 这个是调用add()将记录添加到数据中,这没问题,我的意思是我在jsp页面将userID等赋值,但它通过add()传不进我赋的值;数据库有新纪录,是这个类中成员变量的初始值,而不是我赋的值。我想问的是无参方法中的成员变量怎么才能得到我在jsp页面给它赋的值?
------解决方案-------------------- long userID=2; long goodsID=3; int tag=2;