这是控制台显示的信息
[http-8080-Processor24] ERROR: org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/Exam_online].[jsp]#invoke : Servlet.service() for servlet jsp threw exception
javax.servlet.jsp.JspException: Cannot find bean under name org.apache.struts.taglib.html.BEAN
xml里我不会写bean 请指点。
这个可能是找不到struts的html的那个标签库文件
一个简单的例子,已经测试通过。
struts-config.xml
[code="java"]
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.2//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd">
<!-- -->
<action-mappings>
<action input="/index.jsp" name="helloForm" path="/Hello" scope="request" type="tutorial.action.HelloAction">
<forward name="success" path="/greeting.jsp"/>
</action>
</action-mappings>
<controller processorClass="org.apache.struts.tiles.TilesRequestProcessor"/>
<message-resources parameter="ApplicationResource"/>
<!-- ========================= Tiles plugin ===============================-->
<!--
This plugin initialize Tiles definition factory. This later can takes some
parameters explained here after. The plugin first read parameters from
web.xml, thenoverload them with parameters defined here. All parameters
are optional.
The plugin should be declared in each struts-config file.
- definitions-config: (optional)
Specify configuration file names. There can be several comma
separated file names (default: ?? )
- moduleAware: (optional - struts1.1)
Specify if the Tiles definition factory is module aware. If true
(default), there will be one factory for each Struts module.
If false, there will be one common factory for all module. In this
later case, it is still needed to declare one plugin per module.
The factory will be initialized with parameters found in the first
initialized plugin (generally the one associated with the default
module).
true : One factory per module. (default)
false : one single shared factory for all modules
- definitions-parser-validate: (optional)
Specify if xml parser should validate the Tiles configuration file.
true : validate. DTD should be specified in file header (default)
false : no validation
Paths found in Tiles definitions are relative to the main context.
-->
<plug-in className="org.apache.struts.tiles.TilesPlugin" >
<set-property property="definitions-config" value="/WEB-INF/tiles-defs.xml" />
<set-property property="moduleAware" value="true" />
</plug-in>
<!-- ========================= Validator plugin ================================= -->
<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property
property="pathnames"
value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>
</plug-in>
[/code]
index.jsp
[code="java"]
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
Struts1 Helloworld Example
html:base/
</body>
/html:html
[/code]
HelloAction
[code="java"]
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.DynaActionForm;
/**
*
@author hantsy
*/
public class HelloAction extends Action {
@Override
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws Exception {
DynaActionForm helloForm = (DynaActionForm) form;
String message = "Hello " + helloForm.getString("message");
request.setAttribute("message", message);
return mapping.findForward("success");
}
}
[/code]
greeting.jsp
[code="java"]
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
</body>
[/code]
另外参考我的 Struts 文章。
[url]http://blog.chinaunix.net/u/1096/article_77749.html[/url]
是否是struts-config.xml中配置的动态ActionForm出错了,type应该指向struts中的动态ActionForm,可以通过查看strutsApi查看,接着就要看看配置的属性是否在type中加入完整路径,比如:如果有一个属性是username,那么在配置这个属性的type的时候有没有输入完整路径,这里是String,那么type应该填写Java.lang.String
在Action中获得动态ActionForm中的数据,要看看有没有写错。
接着就是楼上的人说的,那个标签是否导入有效。