我正在尝试将 HDIV 实现到 spring 3.1 应用程序。
我在 pom 文件和监听器中添加了依赖项,在 web.xml 文件中进行了过滤。
我已经完成了如图所示的配置,当我访问应用程序时,欢迎页面正在加载,但之后如果我从屏幕访问任何链接,则会将其重定向到错误页面。
我收到错误为“HDIV_PARAMETER_NOT_EXISTS”
可能是什么问题?
如何在请求中发送 HDIV 参数。我是否需要修改 JSP 以在请求中发送 HDIV 参数?
网页.xml:
<listener>
<listener-class>org.hdiv.listener.InitListener</listener-class>
</listener>
<!-- HDIV Validator Filter -->
<filter>
<filter-name>ValidatorFilter</filter-name>
<filter-class>org.hdiv.filter.ValidatorFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>ValidatorFilter</filter-name>
<!-- Spring MVC Servlet name-->
<servlet-name>mvc-dispatcher</servlet-name>
</filter-mapping>
<jsp-config>
<taglib>
<taglib-uri>http://www.springframework.org/tags/form</taglib-uri>
<taglib-location>/WEB-INF/lib/spring-form.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://www.springframework.org/tags</taglib-uri>
<taglib-location>/WEB-INF/lib/spring.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://java.sun.com/jsp/jstl/core</taglib-uri>
<taglib-location>/WEB-INF/lib/hdiv-c.tld</taglib-location>
</taglib>
</jsp-config>
pom.xml:
<dependency>
<groupId>org.hdiv</groupId>
<artifactId>hdiv-core</artifactId>
<version>${org.hdiv-version}</version>
</dependency>
<dependency>
<groupId>org.hdiv</groupId>
<artifactId>hdiv-config</artifactId>
<version>${org.hdiv-version}</version>
</dependency>
<dependency>
<groupId>org.hdiv</groupId>
<artifactId>hdiv-spring-mvc</artifactId>
<version>${org.hdiv-version}</version>
</dependency>
<dependency>
<groupId>org.hdiv</groupId>
<artifactId>hdiv-jstl-taglibs-1.2</artifactId>
<version>${org.hdiv-version}</version>
</dependency>
配置:
<hdiv:config excludedExtensions="css,png,gif,jpeg,jpg,js" errorPage="/errorPage.jsp">
<hdiv:startPages>/,/index.htm</hdiv:startPages>
</hdiv:config>
<!-- Accepted pattern within the application for all editable parameters (generated from textbox and textarea) -->
<hdiv:validation id="safeText">
<hdiv:acceptedPattern><![CDATA[^[a-zA-Z0-9@.-_]*$]]></hdiv:acceptedPattern>
</hdiv:validation>
<!-- Finally, it's necessary to define editable data validation for the application -->
<hdiv:editableValidations>
<hdiv:validationRule url="/.*">safeText</hdiv:validationRule>
</hdiv:editableValidations>
索引.jsp:
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<html>
<head>
<title>Freight Management Tool</title>
</head>
<body topmargin="0" leftmargin="0" >
<div id="header">
<%@include file="header.jspf"%>
</div>
<div id="content"> </div>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr class="topHeading">
<td>
<% if (request.isUserInRole("FMT_ADMIN")) { %>
<spring:message code = "index.admin"/>
<% } if (request.isUserInRole("FMT_NM")) { %>
<spring:message code = "index.network.mngt"/>
<% } if (request.isUserInRole("FMT_RM")) { %>
<spring:message code = "index.revenue.mngt"/>
<% } if (request.isUserInRole("FMT_SALES")) { %>
<spring:message code = "index.sales"/>
<% } %>
</td>
<td></td>
</tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<br/>
<% if (!request.isUserInRole("FMT_SALES")) { %>
<tr>
<td width="2%"></td>
<td width="15%" class="blackHeading"><spring:message code = "index.welcome"/> <h1><a href="/cargoalflights/SearchCargoalFlightMaster.htm"><spring:message code = "index.cargoal.search"/></a></h1></td>
<td width="63%"></td>
</tr>
<% } else {%>
<tr>
<td width="2%"></td>
<td width="15%" class="blackHeading"><spring:message code = "index.welcome"/> <h1><a href="/datedflight/DatedFlightSearch.htm"><spring:message code = "index.dated.flight.search"/></a></h1></td>
<td width="63%"></td>
</tr>
<% } %>
</table>
</body>
</html>
过时的FlightController.java:
@RequestMapping("/datedflight/DatedFlightSearch.htm")
public ModelAndView datedFlightSearchScreen() {
return new ModelAndView("datedFlightSearch", "datedFlightDTO",
datedFlightDTO);
}