它显示了http 500与jasper错误,在启动应用程序时,我在同一个项目中使用了jersey和struts2。需要任何特定配置。尽管如此,所有jar文件都包含在内,它显示错误。
Web.xml中
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
<display-name>RestExample</display-name>
<welcome-file-list>
<welcome-file>/jsp/login.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>jersey-serlvet</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>com.src.matchmaker.services</param-value>
</init-param>
<init-param>
<param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>jersey-serlvet</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping>
</web-app>
struts.xml中
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.action.excludePattern" value="/rest/.*" />
<!-- Configuration for the default package. -->
<package name="default" extends="struts-default">
</package>
</struts>
的login.jsp
<%--
Document : register
Created on : Jan 31, 2013, 11:18:43 AM
Author : wifin
![enter image description here][1]--%>
<%@page language="java" contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="<%=request.getContextPath()%>/css/match_login_style.css" type="text/css">
<link rel="icon" type="image/jpg" href="<%=request.getContextPath()%>/images/logo.jpg"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Login</title>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery-1.7.2.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery.validation.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/login_validation.js"></script>
</head>
<body>
<div class="wrap">
<div class="back" align="center">
<form id="login" name="login" action="login.action" method="post">
<div align="center" class="header">Login</div>
<div id="err"><s:actionerror/></div>
<div class="tit">
Email Id: <input type="text" name="emailId" id="emailId"/>
<div class="clr"></div>
</div>
<div class="tit">
Password: <input type="password" name="password" id="password"/>
<div class="clr"></div>
</div>
<div>
<input class="btn" type="submit" name="reg" value="Login" id="reg" />
<input class="btn" type="reset" value="Cancel" id="cancel" />
</div>
</form>
<div><a class="link" href="<%=request.getContextPath()%>/jsp/register.jsp">New User?</a></div>
</div>
</div>
</body>
</html>
答案 0 :(得分:0)
您正在显示页面而不通过Struts2过滤器。您需要调用Struts2操作,该操作将显示您的页面。
自Struts 2.1.3起,org.apache.struts2.dispatcher.FilterDispatcher
也被弃用,因此如果您使用的是更高版本,则2.1.3将FilterDispatcher更改为org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
。
为什么不用这个过滤器拦截所有网址模式?将此过滤器<url-pattern>
更改为<url-pattern>/*</url-pattern>
。
在JSP中使用scriptlet的BTW是一种不好的做法,而是使用Struts2标签。