5

我只是尝试在 jsp 页面中包含一个带有 struts 提供标签的文本框。但它的表现非常典型。

在职的

<html:text property="name" value=""></html:text>

不工作

<html:text property="name"></html:text>
所以,没有财产'value',它就不起作用。请帮帮我。

注意:使用tomcat 6.0
bean,逻辑运行良好,并且在 html 中,大多数逻辑运行正常。广播、文本区域、文本是一些引起问题的原因。
JSP文件

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Registration Form</title>
</head>
<body>
<html:text property="name"></html:text>
</body>
</html>

type Exception report

message 

description The server encountered an internal error () that prevented it from fulfilling this request.

exception 

org.apache.jasper.JasperException: An exception occurred processing JSP page /index.jsp at line 14

11: <title>Registration Form</title>
12: </head>
13: <body>
14: <html:text property="name"></html:text>
15: </body>
16: </html>


Stacktrace:
    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:505)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:398)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


root cause 

javax.servlet.ServletException: javax.servlet.jsp.JspException: Cannot find bean: "org.apache.struts.taglib.html.BEAN" in any scope
    org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:852)
    org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:781)
    org.apache.jsp.index_jsp._jspService(index_jsp.java:79)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


root cause 

javax.servlet.jsp.JspException: Cannot find bean: "org.apache.struts.taglib.html.BEAN" in any scope
    org.apache.struts.taglib.TagUtils.lookup(TagUtils.java:864)
    org.apache.struts.taglib.html.BaseFieldTag.prepareValue(BaseFieldTag.java:126)
    org.apache.struts.taglib.html.BaseFieldTag.renderInputElement(BaseFieldTag.java:102)
    org.apache.struts.taglib.html.BaseFieldTag.doStartTag(BaseFieldTag.java:80)
    org.apache.jsp.index_jsp._jspx_meth_html_005ftext_005f0(index_jsp.java:96)
    org.apache.jsp.index_jsp._jspService(index_jsp.java:69)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


note The full stack trace of the root cause is available in the Apache Tomcat/6.0.18 logs.


--------------------------------------------------------------------------------

Apache Tomcat/6.0.18
4

3 回答 3

10

<html:text>标签应该包含在一个<html:form>标签内,该标签定义了动作,因此 ActionForm 实例从中<html:text>获取其值。

于 2012-12-29T16:59:29.257 回答
2

好吧,这<Html:text>是一种用户输入文本,它将从用户端获取值,并将被进一步分配,但值在此标签中不起作用。

假设是<html:form>因为那将具有动作实例,并且将调用动作。您可以为其分配一个隐藏变量值。

所以结构将是

<html:form>
    <html:text/>
</html:form>
于 2013-09-20T09:17:31.873 回答
0

万一其他人偶然发现这篇文章正在寻找钝的javax.servlet.jsp.JspException的解决方案:在任何范围错误消息中找不到bean:“org.apache.struts.taglib.html.BEAN”,我是由不小心将一个 Struts 插入另一个 Struts<html:form>内部<html:form>。错误消息 Struts 并未指出这一点。我通过查看我的页面生成的 HTML 发现了这一点。

于 2017-03-29T22:40:30.000 回答