Java 尝试运行Struts Dispatcher时出现NullPointerException
我试图用Dispatcher运行一个简单的Struts示例,但我发现了以下错误Java 尝试运行Struts Dispatcher时出现NullPointerException,java,jsp,nullpointerexception,struts,struts-config,Java,Jsp,Nullpointerexception,Struts,Struts Config,我试图用Dispatcher运行一个简单的Struts示例,但我发现了以下错误 SEVERE: Servlet.service() for servlet [jsp] in context with path [/StrutsDispatcher] threw exception [java.lang.NullPointerException: Module 'null' not found.] with root cause java.lang.NullPointerException: M
SEVERE: Servlet.service() for servlet [jsp] in context with path [/StrutsDispatcher] threw
exception [java.lang.NullPointerException: Module 'null' not found.] with root cause
java.lang.NullPointerException: Module 'null' not found.
at org.apache.struts.taglib.TagUtils.getModuleConfig(TagUtils.java:755)
at org.apache.struts.taglib.TagUtils.computeURLWithCharEncoding(TagUtils.java:364)
at org.apache.struts.taglib.TagUtils.computeURLWithCharEncoding(TagUtils.java:285)
at org.apache.struts.taglib.html.LinkTag.calculateURL(LinkTag.java:445)
下面是我的JSP页面和struts配置
code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.2//EN"
"http://struts.apache.org/dtds/struts-config_1_2.dtd">
<struts-config>
<display-name> Dispatcher demo</display-name>
<description>Dispatcher beginning </description>
<form-beans>
<form-bean name="DispatchActionForm" type="org.strutsDispatcher.DispatcherActionForm"></form-bean>
</form-beans>
<action-mappings>
<action path="/test" type="org.strutsDispatcher.DispatchActionTest"
parameter="parameter" input="/dispatchAction.jsp" name="DispatchActionForm"
scope="request" validate="false">
<forward name="add" path="/dispathcerActionAdd.jsp"></forward>
<forward name="save" path="/dispathcerActionSave.jsp"></forward>
<forward name="edit" path="/dispathcerActionEdit.jsp"></forward>
</action>
</action-mappings>
</struts-config>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<h3>Dispatcher Action Example</h3>
<p><html:link page="test.do?parameter=add">Call Add section</html:link>
<p><html:link page="test.do?parameter=edit">Call Edit Section</html:link></p>
<p><html:link page="test.do?parameter=save">Call Save Section</html:link></p>
</body>
</html>
stuts配置文件:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.2//EN"
"http://struts.apache.org/dtds/struts-config_1_2.dtd">
<struts-config>
<display-name> Dispatcher demo</display-name>
<description>Dispatcher beginning </description>
<form-beans>
<form-bean name="DispatchActionForm" type="org.strutsDispatcher.DispatcherActionForm"></form-bean>
</form-beans>
<action-mappings>
<action path="/test" type="org.strutsDispatcher.DispatchActionTest"
parameter="parameter" input="/dispatchAction.jsp" name="DispatchActionForm"
scope="request" validate="false">
<forward name="add" path="/dispathcerActionAdd.jsp"></forward>
<forward name="save" path="/dispathcerActionSave.jsp"></forward>
<forward name="edit" path="/dispathcerActionEdit.jsp"></forward>
</action>
</action-mappings>
</struts-config>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<h3>Dispatcher Action Example</h3>
<p><html:link page="test.do?parameter=add">Call Add section</html:link>
<p><html:link page="test.do?parameter=edit">Call Edit Section</html:link></p>
<p><html:link page="test.do?parameter=save">Call Save Section</html:link></p>
</body>
</html>
调度程序演示
调度员开始
JSP页面:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.2//EN"
"http://struts.apache.org/dtds/struts-config_1_2.dtd">
<struts-config>
<display-name> Dispatcher demo</display-name>
<description>Dispatcher beginning </description>
<form-beans>
<form-bean name="DispatchActionForm" type="org.strutsDispatcher.DispatcherActionForm"></form-bean>
</form-beans>
<action-mappings>
<action path="/test" type="org.strutsDispatcher.DispatchActionTest"
parameter="parameter" input="/dispatchAction.jsp" name="DispatchActionForm"
scope="request" validate="false">
<forward name="add" path="/dispathcerActionAdd.jsp"></forward>
<forward name="save" path="/dispathcerActionSave.jsp"></forward>
<forward name="edit" path="/dispathcerActionEdit.jsp"></forward>
</action>
</action-mappings>
</struts-config>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<h3>Dispatcher Action Example</h3>
<p><html:link page="test.do?parameter=add">Call Add section</html:link>
<p><html:link page="test.do?parameter=edit">Call Edit Section</html:link></p>
<p><html:link page="test.do?parameter=save">Call Save Section</html:link></p>
</body>
</html>
在此处插入标题
调度程序操作示例
呼叫添加部分
调用编辑部分
呼叫保存部分
html:link标记属性页面
的值不正确,链接标记实现无法对其求值以创建url。如果您使用的是希望url指向的操作,则使用“操作”属性
<html:link action="/test"><html:param name="parameter" value="save"/></html:link>
其他链接也是如此看看这个问题:@TroyAndAbed,在我发布我的问题之前,我确实看到了那篇帖子他们给出的建议,我尝试了所有建议,但都没有奏效,为什么要重新发布呢