我现在把login.jsp放在根目录下,一访问,就出现404错误。
我把 filter 和下面的 监听器去掉,正常
web.xml<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<!-- 加载struts2核心 -->
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>
<init-param>
<param-name>exclude</param-name>
<param-value>
login.jsp
</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping> <!-- 指明spring配置文件在何处 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:applicationContext.xml</param-value>
</context-param> <!-- 加载spring配置文件applicationContext.xml -->
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
</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.objectFactory" value="spring" />
<package name="struts2" extends="struts-default">
<action name="login" class="LoginAction" method="testStruts">
<exception-mapping result="usernameInvalid" exception="com.exception.UsernameException" />
<exception-mapping result="passwordInvalid" exception="com.exception.PasswordException" />
<result name="success" type="dispatcher">index.jsp</result>
<result name="input" type="dispatcher">login.jsp</result>
<result name="usernameInvalid" type="dispatcher">usernameInvalid.jsp</result>
<result name="passwordInvalid" type="dispatcher">passwordInvalid.jsp</result>
</action>
</package></struts>
我把 filter 和下面的 监听器去掉,正常
web.xml<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<!-- 加载struts2核心 -->
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>
<init-param>
<param-name>exclude</param-name>
<param-value>
login.jsp
</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping> <!-- 指明spring配置文件在何处 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:applicationContext.xml</param-value>
</context-param> <!-- 加载spring配置文件applicationContext.xml -->
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
</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.objectFactory" value="spring" />
<package name="struts2" extends="struts-default">
<action name="login" class="LoginAction" method="testStruts">
<exception-mapping result="usernameInvalid" exception="com.exception.UsernameException" />
<exception-mapping result="passwordInvalid" exception="com.exception.PasswordException" />
<result name="success" type="dispatcher">index.jsp</result>
<result name="input" type="dispatcher">login.jsp</result>
<result name="usernameInvalid" type="dispatcher">usernameInvalid.jsp</result>
<result name="passwordInvalid" type="dispatcher">passwordInvalid.jsp</result>
</action>
</package></struts>
解决方案 »
- static代码块
- 请教面向对象与基于对象的区别
- 一道关于java -classpath参数的问题
- 如何获取图像
- 一个很简单的问题,我就是搞不定(散分80)
- 我有一个c++编写的dll文件,如何在java中调用
- 现在两个字符串:str1="2002-10-30 12:45:00",str2="2002-12-14 08:09:20",请问怎样判断str1的日期是否在str2的日期之前还是之后?要不
- 如何在客户端不通过提交就刷新?在线人数统计时,当用户离线时,如何让它减一?谢谢!
- 终于从项目实施的地狱中完整回来了,欢迎探讨有关经验。散分了。
- 有关ArrayList集合迭代的问题
- 用ldap修改active dirctory 用户密码,SSL问题
- eclipse问题,高手请进~
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>改为</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping>
我都奇了怪了,网上也都是讲这个配的呀
第一.
spring+struts一定要导入的包:
commons-logging-1.0.4.jar (没这个包,不会打印出错信息)
ognl-2.7.3.jar
spring.jar
struts2-core-2.1.8.1.jar
struts2-spring-plugin-2.1.8.1.jar
xwork-core-2.1.6.jar
freeer-2.3.15.jar
commons-fileupload-1.2.1.jar前面因为少了commons-logging-1.0.4.jar。连错误信息都不会打印
第二
在前面的过滤中 filter 中
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
我试着把/* 改为 /*.action 或 *.action 会出现,
希望大家再遇到此类的问题不要再走弯路