struts2配置环境求解
struts.xml代码程序代码:
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts. <!-- struts2的action必须放在一个指定的包空间下定义 --> <package name="default" extends="struts-default"> <!-- 定义处理请求URL为LoginAction.action的Action --> <action name="LoginAction.do" class="com.action.LoginAction" method="execute"> <!-- 定义处理结果字符串和资源之间的映射关系 --> <result name="SUCCESS">/success.jsp</result> <result name="ERROR">/error.jsp</result> </action> </package> </struts>
web.xml
程序代码:
<?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" xmlns="http://java. xmlns:xsi="http://www. xsi:schemaLocation="http://java. http://java. <!-- 定义Struts 2的FilterDispatcher的Filter --> <welcome-file-list> <welcome-file>login.jsp</welcome-file> </welcome-file-list> <filter> <!-- 定义核心Filter的名字 --> <filter-name>struts2</filter-name> <!-- 定义核心Filter的实现类 --> <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> </filter> <!-- FilterDispatcher用来初始化Struts 2并且处理所有的Web请求 --> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> </web-app>
login.jsp
程序代码:
<%@ page language="java" contentType="text/html; charset=GBK" pageEncoding="GBK"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www. http-equiv="Content-Type" content="text/html; charset=GBK"> <title>登陆页面</title> </head> <body> <form action="/LoginAction" method="post" id="testsub"> <input type="text" name="username"> <input type="text" name="password"> <input type="submit" name="提交"> </form> </body> </html>
报错的情况是The requested resource (/struts2/LoginAction.do) is not available.
这是什么情况,调试好一会,哪里有问题?