java org.apache.struts.taglib.html.BEAN 没有找到

index.jsp

  1. <body>
  2. <a href="login2.do">登陆(struts标签)</a><br>
  3. </body>

struts-config.xml

  1. <action path="/login2"
  2. forward="/login_use_struts_tag.jsp"
  3. ></action>
  4. <action path="/loginusetag"
  5. type="com.tangjian.action.LoginAction"
  6. name="loginForm"
  7. >
  8. <forward name="success" path="/login_success.jsp"/>
  9. <forward name="error" path="/login_use_struts_tag.jsp"/>
  10. </action>

login_use_struts_tag.jsp

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

运行之后,报了如下错误:

  1. 严重: Servlet.service() for servlet jsp threw exception
  2. javax.servlet.jsp.JspException: Cannot find bean: "org.apache.struts.taglib.html.BEAN" in any scope
  3. at org.apache.struts.taglib.TagUtils.lookup(TagUtils.java:935)
  4. at org.apache.struts.taglib.html.BaseFieldTag.prepareValue(BaseFieldTag.java:121)
  5. at org.apache.struts.taglib.html.BaseFieldTag.renderInputElement(BaseFieldTag.java:102)
  6. at org.apache.struts.taglib.html.BaseFieldTag.doStartTag(BaseFieldTag.java:81)
  7. at org.apache.jsp.login_005fuse_005fstruts_005ftag_jsp._jspx_meth_html_005ftext_005f0(login_005fuse_005fstruts_005ftag_jsp.java:100)
  8. at org.apache.jsp.login_005fuse_005fstruts_005ftag_jsp._jspService(login_005fuse_005fstruts_005ftag_jsp.java:68)
  9. at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
  10. at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
  11. at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
  12. at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
  13. at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
  14. at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
  15. at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
  16. at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
  17. at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:679)
  18. at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:461)
  19. at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:399)
  20. at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301)
  21. at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1085)
  22. at org.apache.struts.action.RequestProcessor.internalModuleRelativeForward(RequestProcessor.java:1023)
  23. at org.apache.struts.action.RequestProcessor.processForward(RequestProcessor.java:572)
  24. at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:221)
  25. at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
  26. at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
  27. at javax.servlet.http.HttpServlet.service(HttpServlet.java:627)
  28. at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
  29. at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
  30. at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
  31. at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
  32. at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172)
  33. at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
  34. at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
  35. at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
  36. at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
  37. at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:873)
  38. at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
  39. at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
  40. at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
  41. at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
  42. at java.lang.Thread.run(Thread.java:619)
  43. 2010-1-11 0:17:22 org.apache.catalina.core.StandardWrapperValve invoke

一开始报错后,总感觉没错。 
到最后把使用的标签全部换成struts的运行了下才好了。也就是把form标签也改成struts的标签。 
更改的login_use_struts_tag.jsp

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

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

原文出自:http://tj-dragon.iteye.com/blog/567159

上一篇:CocoaPods报错:The dependency `xxx` is not used in any concrete target


下一篇:(二)微信小程序的三种传值方式