public static void main(String[] args)
这个是执行入口,在你的类里应该不需要的你说的 取得db类的参数 不懂什么意思

解决方案 »

  1.   

    回楼上的:
    就是用String str1 = (String)session.getAttribute("str");
    取得DB里面的str。
    我知道public static void main(String[] args)这个不需要,我只是想打出来测试一下。
      

  2.   

    1.你的调用机制弄反了
    public String Connect(){
    String nameStr = "";
    ....
    while(rs.next()) {
        // String str = rs.getString(1);
        nameStr = rs.getString(1); 
        System.out.println(str);
        }
    ....
    return nameStr;
    }在
    public ActionForward execute(ActionMapping actionMapping,
                                   ActionForm actionForm,
                                   HttpServletRequest httpServletRequest,
                                   HttpServletResponse httpServletResponse) 
    {
    .....
    // String str1 = (String)session.getAttribute("str");
    String str1 = (new DB()).connect();
    .....}说明:session一般是保存从页面来的数据,也就是来自web层,然后一层一层传下去,在Action里拿到它然后作为参数传到DB层的函数进行执行,DB层把结果数据传回(通过返回值),在到Action里拿到结果。。知道了把
    HTTP-->request/session--->Action-->call Cmd/DB methods-->return result to Action^_^
    }