struts2第一个例子404错误问题

dixing 2010-01-15 09:13:29
错误信息:
type Status report
message /login/loginAction.action
description The requested resource (/login/loginAction.action) is not available.

代码:
LoginAction.java
package com.sun.action;

import com.opensymphony.xwork2.ActionSupport;
import com.sun.bean.User;

public class LoginAction extends ActionSupport{
/**
*
*/
private static final long serialVersionUID = 1L;
private User user;

public User getUser() {
return user;
}

public void setUser(User user) {
this.user = user;
}

public String execute(){
return SUCCESS;
}
}

ok.jsp
<%@ page language="java" contentType="text/html;" 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=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
欢迎登陆!
</body>
</html>

struts.xml
<?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="login" extends="struts-default">
<action name="loginAction" class="com.sun.action.LoginAction">
<result>/ok.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">
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>


说明:
struts.xml放在\myStruts2-1\pages\WEB-INF\classes目录下
用到的包:
commons-fileupload-1.2.1.jar
commons-io-1.3.2.jar
commons-logging-1.1.jar
freemarker-2.3.13.jar
junit-3.8.1.jar
ognl-2.6.11.jar
spring-test-2.5.6.jar
struts2-core-2.1.6.jar
xwork-2.1.2.jar


...全文
332 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
hjjk123 2010-01-15
  • 打赏
  • 举报
回复
404错误是找不到指定网页的错误.....
zys2419740 2010-01-15
  • 打赏
  • 举报
回复
/login/loginAction.action) is not available. 说你这个Action不可用!另外404错误时因为你的struts.xml的问题,好好看看你的配置文件
dixing 2010-01-15
  • 打赏
  • 举报
回复
还是404,,,,,
http://localhost:8080/login/loginAction.action
http://localhost:8080/loginAction.action
http://localhost:8080/login.action

这些访问都一样404错误

程序是放在根目录,所以没有虚拟目录.
拼搏 2010-01-15
  • 打赏
  • 举报
回复
http://localhost:8080/项目名称/login/loginAction.action
dixing 2010-01-15
  • 打赏
  • 举报
回复
各位,这里的项目名称就是我设置的虚拟目录名称是吧?如果是根目录这里就是空的啦,对吗?
redlotus_lyn 2010-01-15
  • 打赏
  • 举报
回复
http://localhost:8080/项目名称/login.action
lewis219 2010-01-15
  • 打赏
  • 举报
回复
少一个项目名称
http://localhost:8080/项目名称/login/loginAction.action
dixing 2010-01-15
  • 打赏
  • 举报
回复
我是在URL直接访问ACTION
http://localhost:8080/login/loginAction.action

报404了
tuo_bing 2010-01-15
  • 打赏
  • 举报
回复
调用 LoginAction 的 jsp 没有贴出来 ?应该是路径问题 "/login/loginAction.action "
qianmz 2010-01-15
  • 打赏
  • 举报
回复
你的工程名师login???
chenguangwei 2010-01-15
  • 打赏
  • 举报
回复
http://localhost:8080/项目名称/login.action
  • 打赏
  • 举报
回复
找不到资源。路径写错了
yzsunlight 2010-01-15
  • 打赏
  • 举报
回复
没虚拟目录是不行的 建议加上虚拟目录在试

81,094

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧