struts配置求解解决思路

struts配置求解
struts2配置环境求解
struts.xml代码
程序代码:
<!DOCTYPE struts PUBLIC
        "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
        "http://struts.apache.org/dtds/struts-2.0.dtd">
<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.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">

    <!-- 定义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.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta 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.
这是什么情况,调试好一会,哪里有问题?

------解决方案--------------------
引用:
Quote: 引用:

Quote: 引用:

有人吗?人都哪去了


说的是地址引用错误,一般都是粗心造成的。<action name="LoginAction.do" class="com.action.LoginAction" method="execute">中的'.do'去掉。

你可不可以写一个例子给我,包含我上面的三个文件的。


<%@ page language="java" contentType="text/html; charset=GBK"
    pageEncoding="GBK"%>
<!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=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>

package com.action;
import com.opensymphony.xwork2.ActionSupport;

public class LoginAction extends ActionSupport {
public String execute(){

System.out.println("12121");
return "SUC";
}
}

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
        "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
        "http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="test-default" extends="json-default">
<action name="LoginAction" class="com.action.LoginAction" method="execute">