后台取值问题

戏子 2012-04-09 03:02:45
daoImpl

public Information findInformation(int userId){
List list=new ArrayList<Information>();

HibernateTemplate ht=new HibernateTemplate(this.sf);
System.out.println("userId:"+userId);
list=ht.find("from Information where userId="+userId);
Information info=(Information)list.get(0);
System.out.println("用户真实姓名:"+info.getInfoName());//此处可以获取值

return info;
}

action

public String loginBlogs(){
ubdi.findInformation(ub.getUserId());
Information info=new Information();
System.out.println("信息:"+info.getInfoName());//此处不可以获取值
return "blogsok";
}


请大侠帮忙怎么在action中获取这个值,需要把值放入map所以才需要获取
...全文
161 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
戏子 2012-04-09
  • 打赏
  • 举报
回复
[Quote=引用 10 楼 的回复:]

用一个对象接收你传过来的对象, 如果你用new 就产生了另外一个空对象 给分
[/Quote]
嗯,谢谢了
xyong1325 2012-04-09
  • 打赏
  • 举报
回复
用一个对象接收你传过来的对象, 如果你用new 就产生了另外一个空对象 给分
戏子 2012-04-09
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 的回复:]

表示怀疑。
[/Quote]
5楼的方法可以取到值
戏子 2012-04-09
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 的回复:]

Java code


public String loginBlogs(){
//ubdi.findInformation(ub.getUserId());
//Information info=new Information();
Information info=ubdi.findInformation(ub.getUserId());……
[/Quote]
可以了,能解释一下吗?info=ubdi.findInformation();
im110 2012-04-09
  • 打赏
  • 举报
回复
表示怀疑。
戏子 2012-04-09
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 的回复:]

按你的意思应该是这样:
Information info = new Information();
info = ubdi.findInformation(ub.getUserId());
[/Quote]

这样也不行我试过了,得到的时null
xyong1325 2012-04-09
  • 打赏
  • 举报
回复


public String loginBlogs(){
//ubdi.findInformation(ub.getUserId());
//Information info=new Information();
Information info=ubdi.findInformation(ub.getUserId()); System.out.println("信息:"+info.getInfoName());//此处不可以获取值
return "blogsok";
}
这样应该就可以取到值了



戏子 2012-04-09
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 的回复:]

你new了info 当然取不到值啦 先new 然后再取
[/Quote]
得到的还是null
im110 2012-04-09
  • 打赏
  • 举报
回复
按你的意思应该是这样:
Information info = new Information();
info = ubdi.findInformation(ub.getUserId());

戏子 2012-04-09
  • 打赏
  • 举报
回复
Information info=new Information();
放在
ubdi.findInformation(ub.getUserId());
前面?
fangkaifang 2012-04-09
  • 打赏
  • 举报
回复
你new了info 当然取不到值啦 先new 然后再取

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧