错误信息:
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
freeer-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
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
freeer-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
http://localhost:8080/login/loginAction.action报404了
http://localhost:8080/项目名称/login/loginAction.action
http://localhost:8080/login/loginAction.action
http://localhost:8080/loginAction.action
http://localhost:8080/login.action这些访问都一样404错误程序是放在根目录,所以没有虚拟目录.