struts 怎么会404 文件存在?404要注意些什么东西?

web.xml

部份:

struts2
org.apache.struts2.dispatcher.FilterDispatcher


struts2
/*

struts.xml


/st.jsp
/two.jsp

Hello.java

package pkone;
import com.opensymphony.xwork2.ActionSupport;
//
public class Hello extends ActionSupport{
/**

  • */ private static final long serialVersionUID = 1L; //org.apache.struts2.dispatcher.FilterDispatcher d = new org.apache.struts2.dispatcher.FilterDispatcher(); public String execute() throws Exception { System.out.println("langzis++!!!!!!!!!!"); return "success"; //return SUCCESS; //return "error"; } }

http://127.0.0.1/test/he/hello.action 来来去去都是404
http://127.0.0.1/test/webroot/ ~~却能正常访问

404一般是访问的资源不存在,检查自己的url是否正确。
推荐去看下web服务的资源路径和绝对路径的关系。

500一般是页面出现问题,比如jsp编译出错。

WebRoot目录下是否存在/st.jsp。请注意这个

如果路径是全路径那么是/开头,如果是相对路径那么请不要/开头,所以你要看看你的result那个跳转页面是否是根目录下的。
还有./代表当前目录,../代表上一级目录。
struts2是*.action,请严格按照规范来,那样出现错误的几率比较小。