struts2事例程序 访问action失败 404错说是请求资源无效 后台也不报错

 <package name="main"  namespace="/" extends="struts-default">
 <action name="time_reference" class="com.jin.gzzd.Time_reference" method="execute">
 <result name="SUCCESS">index.jsp</result>
 </action>
 </package>




<!-- Add packages here -->



version1

index.html
index.htm
index.jsp
default.html
default.htm
default.jsp

<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>


package com.jin.gzzd;

import com.opensymphony.xwork2.ActionSupport;

public class Time_reference {
private String name;
private int age;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public String execute() throws Exception
{
System.out.println("jinru");
return "SUCCESS";
}
}
![图片说明](https://img-ask.csdn.net/upload/201612/28/1482907446_540230.png)图片说明

话说,你的action类没有居然没继承ActionSupport.将public class Time_reference {改成public class Time_reference extends ActionSupport {

为什么你导包了 居然没继承

一般使用struts2
返回视图名称都是SUCCESS常量(可以看Action接口的定义),不是字符串
index.jsp



/index.jsp

<action name="time_reference.action"