- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我收到这个错误:
javax.servlet.ServletException: bean not found within scope
在顶部有这个的页面上。
<jsp:useBean id="bean" type="com.example.Bean" scope="request" />
该类存在于类路径中,它今天早上工作,但我不明白 not found within scope 是什么意思。
这是怎么引起的,我该如何解决?
最佳答案
您需要 class
属性而不是 type
属性。
以下内容:
<jsp:useBean id="bean" type="com.example.Bean" scope="request" />
基本上在幕后做了以下事情:
Bean bean = (Bean) pageContext.getAttribute("bean", PageContext.REQUEST_SCOPE);
if (bean == null) {
throw new ServletException("bean not found within scope");
}
// Use bean ...
虽然以下内容:
<jsp:useBean id="bean" class="com.example.Bean" scope="request" />
基本上在幕后做了以下事情:
Bean bean = (Bean) pageContext.getAttribute("bean", PageContext.REQUEST_SCOPE);
if (bean == null) {
bean = new Bean();
pageContext.setAttribute("bean", bean, PageContext.REQUEST_SCOPE);
}
// Use bean ...
如果它以前工作过但“突然”不工作,则意味着负责将 bean 放入作用域中的某物 已停止工作。例如,在 doGet()
中执行以下操作的 servlet:
request.setAttribute("bean", new Bean());
request.getRequestDispatcher("page.jsp").forward(request, response);
也许您已经通过URL 直接调用了JSP 页面,而不是通过URL 调用了Servlet。如果您想禁用对 JSP 页面的直接访问,请将它们放在 /WEB-INF
中并转发给它。
关于javax.servlet.ServletException : bean [name] not found within scope,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/270444/
想法:2018.3 jetty :9.4.11 我按照 IDEA 中给出的说明下载了 jrebel 文件夹 在 Debug模式下运行 Jetty 服务器时出现以下错误。 HTTP ERROR 500
我刚刚加入了一个新团队,我正在尝试使用 GWT 在 Eclipse 中运行他们的项目。我知道代码没问题,但我不断收到类似的错误。 javax.servlet.ServletException:org.
我在 WAS7 中使用 JSF 2.1 mojjara 和 primefaces 3.5 我完成了从我的 JSF jar 和其他组件加载 FacesServlet 的集成 我现在面临的问题如下: 最佳
我在 java 文件中遇到错误,因为 ServletException 无法解析为类型 该行有多个标记 - HttpServletRequest 无法解析为 类型 - HttpServletRespo
我设置服务器的经验几乎为零,但目前我的工作是设置一台(不要问为什么)。这是一个 apache-tomcat6 服务器。 我一步步遵循了一些说明,当需要测试一切是否正常时,我得到的是: 我知道这有点盲目
我只是设置一个简单的测试类。代码补全可以在 Eclipse 中工作,但我无法启动该页面: 支持 bean: @Named @RequestScoped public class TestBean {
...我永远无法在这两者之间做出决定。我总是回到代码并在之间切换。 当您从(扩展的)HttpServlet 编码时(假设是一个 Login 类),它同时支持 ServletException 和 IO
使用Kotlin,我具有以下依赖关系: implementation("org.springframework.boot:spring-boot-starter-web") implementatio
我收到 javax.faces.FacesException: Value of 'groupList 'must be an array or a collection 错误。我用谷歌搜索了它,但我
我正在尝试在 Eclipse 上运行示例基本 REST API,但一直收到 ServletException。 代码如下: 员工.java package net.javabeat.articles.
我使用 tomcat 7.0.29,当我部署我的应用程序(一个小程序)并从 eclipse 启动 tomcat 时,我收到了这个错误。 严重:Servlet/test 抛出 load() 异常 jav
我在我的网络应用程序中打开其中一个页面时遇到了一个非常奇怪的错误。该应用程序基于 Seam 2.2 构建,并在表示层中使用 JSF (RichFaces)。我在 Tomcat 6 上运行它。 在日志中
我喜欢使用 spring-security 模块,但是当我按照 spring 项目的教程 ( http://docs.spring.io/spring-security/site/docs/3.2.x
我在执行以下代码时收到 javax.servlet.servletException.... " " " tiles:importAttribute scope="request"/> h:panel
我正在尝试使用以下代码创建 javax.servlet.ServletException 类的实例 public class MyTroubleViewer { public static void
我过去一直在抛出 ServletException,当 Servlet 出现问题时,主要是将异常包装在 ServletException 中。 现在我认为最好不要抛出 ServletException
这个问题在这里已经有了答案: How do I import the javax.servlet / jakarta.servlet API in my Eclipse project? (15 个回
这里我编写了一些代码,用于从数据库中检索值并传递一些值。 下面是Action类代码: AttendenceServiceImpl serveceimpl; public ActionForwar
说明: 我有一个在支持 bean 中设置成员的 JSF 命令链接,但是,当使用 setPropertyActionListener 设置支持 bean 成员时,出现标记无法识别的错误。 该项目构建和部
我是 ICEFACES 的初学者,尝试使用一些 ICEFACES 组件成功运行我的第一个 ICEFACES 屏幕。开始使用。我正在使用 ICEFACES 1.8.2。 我从此链接复制了 web.xml
我是一名优秀的程序员,十分优秀!