簡體   English   中英

當我嘗試運行Struts Dispatcher時出現NullPointerException

[英]NullPointerException when I try to run Struts Dispatcher

我正在嘗試使用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值不正確,link標記實現無法評估它來創建url。 如果您使用動作,則要使用url來使用動作屬性。

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

等其他鏈接

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM