如何在Servlet中获取Java bean值?

问题描述 投票:-1回答:1
AdminBean bean=new AdminBean();

        String uname=bean.getPass();
        String pass=bean.getPass();
        out.println(bean.getUname());
        out.println(bean.getPass());

打印空值

java servlets model-view-controller
1个回答
0
投票

您没有为对象设置值,需要为属性设置值。

        AdminBean bean=new AdminBean();
        bean.setPass("123455");
        bean.setUname("ABC");
        String uname=bean.getPass();
        String pass=bean.getPass();
        out.println(bean.getUname());
        out.println(bean.getPass());
© www.soinside.com 2019 - 2024. All rights reserved.