gpt4 book ai didi

java - 当我尝试运行 Struts Dispatcher 时出现 NullPointerException

转载 作者:行者123 更新时间:2023-12-01 14:23:30 24 4
gpt4 key购买 nike

我正在尝试使用 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: 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-config 代码:

stuts-config 文件:

<?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>

JSP 页面:

<%@ 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&#63;parameter=add">Call Add section</html:link>
<p><html:link page="test.do&#63;parameter=edit">Call Edit Section</html:link></p>
<p><html:link page="test.do&#63;parameter=save">Call Save Section</html:link></p>
</body>
</html>

最佳答案

html:link 标记属性 page 的值不正确,链接标记实现无法评估它来创建 url。如果您使用要 url 的操作,则使用操作属性。

<html:link action="/test"><html:param name="parameter" value="save"/></html:link>

其他链接依此类推

关于java - 当我尝试运行 Struts Dispatcher 时出现 NullPointerException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17347157/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com