为什么我每次配置struts2运行都会出现以下报错,我从网上查了,是找不到路径,但我不知道怎么写:HTTP Status 404 - /hello-strust2/--------------------------------------------------------------------------------type Status reportmessage /hello-strust2/description The requested resource (/hello-strust2/) is not available.
--------------------------------------------------------------------------------Apache Tomcat/6.0.13=========================================以下是源代码================================
    
  login.jsp<%@page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<%@ taglib uri="/struts-tags" prefix="s" %>
<html>
<body>
<div align="center">
<s:form action="login.action" method="post">
<s:textfield name="username" lable="用户名"></s:textfield>
<s:textfield name="password" lable="密码"></s:textfield>
<s:submit value="登录系统"></s:submit>
</s:form>
</div>
</body>
</html>
      login-error<%@page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<html>
<body>
<h1>登录失败</h1>
</body>
</html>
  login-success<%@page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<html>
<body>
<h1>成功</h1>
</body>
</html>
  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" version="3.0">
  <display-name></display-name>
  <welcome-file-list>
  <welcome-file>login.jsp</welcome-file>
  </welcome-file-list>
  <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>
</web-app>
  struts.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd">
<struts>
<package name="struts2" extends="struts-default">
<action name="login" class="com.icar.action.LoginAction">
<result name="success">login-success</result>
<result name="error">login-error</result>
</action>
</package>
</struts>   
  LoginAction
package com.icar.actions;
import com.opensymphony.xwork2.ActionSupport;
public class LoginAction {
private String username;
private String password;
public String getUsername(){
return username;
}
public void setUsername(String username){
this.username=username;
}
public String getpassword(){
return password;
}
public void setpassword(String password){
this.password=password;
}
public String execute(){
if(username.equals("123")&&password.equals("123")){
return SUCCESS;
}else
return ERROR;}}============================================================================================================
还有,我只想页面出现登陆页面,然后我写了一个 login.jsp,然后它报错了,和上面的一样,我从网上查了,是找不到路径,但不知道怎么写,代码如下:<%@page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<%@ taglib uri="/struts-tags" prefix="s" %>
<html>
<body>
<div align="center">
<s:form action="" method="post">
<s:textfield name="username" lable="用户名"></s:textfield>
<s:textfield name="password" lable="密码"></s:textfield>
<s:submit value="登录系统"></s:submit>
</s:form>
</div>
</body>
</html>  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" version="3.0">
  <display-name></display-name>
  <welcome-file-list>
  <welcome-file>login.jsp</welcome-file>
  </welcome-file-list>
  <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>
</web-app>

解决方案 »

  1.   

    <result name="success">login-success.jsp</result>
    <result name="error">login-error.jsp</result>
    目测就这里出错
      

  2.   

    你要先看在启动tomcat的时候有没有报错,启动报错,肯定404,你的result和楼上说的一样,有错,应该是<result name="error">/login-error.jsp</result>
      

  3.   

    description The requested resource (/hello-strust2/) is not available.你的应用未能部署成功,也就是说出现的错误连初始运行都不能。