照书上打了一个struts2的示例程序,就是无法用浏览器进入hello.jsp,于是把所有文件精简,只留下hello.jsp和web.xml。
hello.jsp的内容是
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>struts2 app</title>
</head>
<body>
helloworld
</body>
</html>
web.xml的内容是
<?xml version="1.0" encoding="UTF-8"?>
<web-app>
<filter>
<filter-name>struts2</filter-name>
<fitler-class>org.apache.struts2.dispatcher.FilterDispatcher</fitler-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
发现把web.xml删了就能进入hello.jsp了(这个倒也在情理之中),我想问的是,过滤器FilterDispatcher究竟会对jsp文件做什么,如果过滤器只对action后缀的请求才转发到struts.xml,那为什么请求一个jsp会出现503错误呢,请求各位回答,感激不尽啊。。
------解决方案--------------------
有没hello这个action啊
------解决方案--------------------
你用的Struts2的话 那么你的xml文件写的有问题了
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>