一开始能进去action里,运行完后就显示404错误,路径少了项目名,不知哪错了



------解决方案--------------------
path的路径有问题吧?
------解决方案--------------------
地址栏里填写啊,你那localhost:8080不是自己输入的吗
------解决方案--------------------
哦 那就在path中写上项目名
------解决方案--------------------
可以用js先获取项目名,请求action的时候再加上:
getRootPath : function(){
var rootpath = "";
try{
// 获取当前网址
var strFullPath = window.document.location.href;
var strPath = window.document.location.pathname;
// 获取主机地址,
var prePath = strFullPath.substring(0, strFullPath.indexOf(strPath));
// 获取带"/"的项目名
var postPath = strPath.substring(0, strPath.substr(1).indexOf('/') + 1);
rootpath = (prePath + postPath+"/");//项目名不是root
//rootpath = (prePath +"/");//项目名改为Root
}catch(e){
alert("获取项目根路径失败");
};
return rootpath;
}
然后请求action的时候getRootPath()+"xxxx.action"
------解决方案--------------------
你使用编译器运行web项目可以不加项目名,使用tomcat就要加,如果不更改webapps路径的话。
------解决方案--------------------
你加上项目名不能访问吗,还是你想不使用项目名,直接访问tomcat就是访问这个项目。
------解决方案--------------------
帖一下 /login/login.jsp 的代码
------解决方案--------------------
/login/login.jsp看这里<forward name="loginFailure" path="login/login.jsp"/>
path后边不要加/这个斜杠了
------解决方案--------------------
我感觉楼主是不是把这个login.jsp页面放在web info 目录下了
------解决方案--------------------
加了报错
加上项目名字试一试。
改成这样。
/login/login.jsp看这里<forward name="loginFailure" path="项目名/login/login.jsp"/>
把你的action配置文件来一下 localhost:8080/你的项目名/action命名空间/action.html
