jsp通过什么来识别bean对象(关于 jsp+servlet+bean 的数据库查询 用bean方法输出 这是我写的用jdbc mysql数据库)

本文目录
- 关于 jsp+servlet+bean 的数据库查询 用bean方法输出 这是我写的用jdbc mysql数据库
- spring2.5 使用注解的时候jsp如何获得bean对象
- 如何在java类中和jsp页面取Spring bean对象
关于 jsp+servlet+bean 的数据库查询 用bean方法输出 这是我写的用jdbc mysql数据库
在Link这个Servlet中,你虽然将sql语句执行的结果放在了UserInfo这个Bean里,但是你没有将UserInfo的对象us放到request作用域中,应该是request.setAttribute("key",us),而不是request.setAttribute("key",re);
《jsp:useBean id" type="bean.UserInfo" scope="request"》《/jsp:useBean》在执行时,由于设置的scope是request域,因此服务器会在request域中查找UserInfo这个Bean的对象,若找不到就会报告错误。。
这是我的理解,望采纳!谢谢!
spring2.5 使用注解的时候jsp如何获得bean对象
WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext((request).getSession().getServletContext());
AdvertiseService advertiseService = (AdvertiseService)ctx.getBean("advertiseService");
这个是在容器里调 一个service的
如何在java类中和jsp页面取Spring bean对象
ServletContext context = req.getServletContext();
WebApplicationContext appContext =
WebApplicationContextUtils.getWebApplicationContext(context);
// 获得userService实例
userService = (UserService)context.getBean("userService");

更多文章:
怎么看有没有装jdk(在windows系统下怎么查看有没有安装jdk)
2025年11月1日 17:15
websocket浏览器兼容(websocket怎样兼容ie8)
2025年5月24日 04:30
excel乘法函数怎么输入(excel表格函数乘法 excel表格里如何乘法函数公式)
2025年8月8日 11:45
苏州公司网站设计(苏州网站建设流程是什么苏州专业网站策划哪家最好)
2025年8月26日 05:15
constructed environment翻译(翻译下面这段文字)
2025年9月26日 03:00
java字符串截取后两位(JAVA截取所有指定字符后面的字符串)
2025年12月5日 23:15
墨迹天气插件(vivo手机的桌面插件在哪里能找到,我安装墨迹天气,设置桌面时钟,都不知道装在哪)
2026年6月5日 02:15
excludefrom的用法(excluded from boot order什么意思)
2026年3月26日 11:45
intellectual enjoyment翻译(英语翻译一下这段话哦)
2026年4月28日 00:15














