当前位置: 代码迷 >> HTML/CSS >> Cannot find bean: "org.apache.struts.taglib.html.BEAN" in any scope 有关问题
  详细解决方案

Cannot find bean: "org.apache.struts.taglib.html.BEAN" in any scope 有关问题

热度:1229   发布时间:2012-11-10 10:48:51.0
Cannot find bean: "org.apache.struts.taglib.html.BEAN" in any scope 问题
学习的时候,由于自己没在意,碰到了html标签和struts1标签混用出错的情况。

index.jsp
  <body>
    <a href="login2.do">登陆(struts标签)</a><br>
  </body>


struts-config.xml
<action path="/login2"
        forward="/login_use_struts_tag.jsp"
    ></action>
<action path="/loginusetag"
        type="com.tangjian.action.LoginAction"
        name="loginForm"
    >
    <forward name="success" path="/login_success.jsp"/>
    <forward name="error" path="/login_use_struts_tag.jsp"/>
</action>


login_use_struts_tag.jsp
<body>
	<h1>用户登陆-使用struts标签保持数据</h1>
	<hr>
	<form action="loginusetag.do" method="post">
		用户名:<html:text property="username"/><br>
		密&nbsp;&nbsp;码:<html:password property="password" value=""/><br>
		<input type="submit" value="提交">
	</form>
</body>


运行之后,报了如下错误:
严重: Servlet.service() for servlet jsp threw exception
javax.servlet.jsp.JspException: Cannot find bean: "org.apache.struts.taglib.html.BEAN" in any scope
	at org.apache.struts.taglib.TagUtils.lookup(TagUtils.java:935)
	at org.apache.struts.taglib.html.BaseFieldTag.prepareValue(BaseFieldTag.java:121)
	at org.apache.struts.taglib.html.BaseFieldTag.renderInputElement(BaseFieldTag.java:102)
	at org.apache.struts.taglib.html.BaseFieldTag.doStartTag(BaseFieldTag.java:81)
	at org.apache.jsp.login_005fuse_005fstruts_005ftag_jsp._jspx_meth_html_005ftext_005f0(login_005fuse_005fstruts_005ftag_jsp.java:100)
	at org.apache.jsp.login_005fuse_005fstruts_005ftag_jsp._jspService(login_005fuse_005fstruts_005ftag_jsp.java:68)
	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
	at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
	at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
	at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:679)
	at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:461)
	at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:399)
	at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301)
	at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1085)
	at org.apache.struts.action.RequestProcessor.internalModuleRelativeForward(RequestProcessor.java:1023)
	at org.apache.struts.action.RequestProcessor.processForward(RequestProcessor.java:572)
	at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:221)
	at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
	at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:627)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:873)
	at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
	at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
	at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
	at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
	at java.lang.Thread.run(Thread.java:619)
2010-1-11 0:17:22 org.apache.catalina.core.StandardWrapperValve invoke


一开始报错后,总感觉没错。
到最后把使用的标签全部换成struts的运行了下才好了。也就是把form标签也改成struts的标签。
更改的login_use_struts_tag.jsp
<body>
	<h1>用户登陆-使用struts标签保持数据</h1>
	<hr>
	<html:form action="loginusetag.do" method="post">
		用户名:<html:text property="username"/><br>
		密&nbsp;&nbsp;码:<html:password property="password" value=""/><br>
		<input type="submit" value="提交">
	</html:form>
</body>


为什么html标签和struts的标签不能混用的原因没有去深究,只是给自己提个醒:以后页面尽量不要使用不同风格的标签,这样感觉应该不会错吧!
  相关解决方案