在action中execute能执行但是在return时出现404只是为啥呀,请大侠们帮忙呗!该如何解决
发布时间:2010-06-14 18:41:54 文章来源:www.iduyao.cn 采编人员:星星草
在action中execute能执行但是在return时出现404只是为啥呀,请大侠们帮忙呗!
我struts.xml:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd">
<struts>
<package name="Scopename" namespace="" extends="struts-default">
<action name="login" class="actions.LoginAction">
<result name="success" >/findLover.jsp</result>
<result name="error" >/Login.jsp</result>
</action>
<action name="register" class="actions.UserRegisterAction">
<result name="success" type="dispatcher">/Login.jsp</result>
<result name="error" type="dispatcher">/FailureRegister.jsp</result>
</action>
</package>
</struts>
提交的Login.jsp 为:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>欢迎登录交友网</title>
</head>
<body>
<form method="post" action="login.action"
style="background-color: rgb(20, 96, 85);">
<center>
<font color="#800040">赶快登陆吧</font>
</center>
<hr>
用户名:
<input id="userNameID" type="text" name="name" align="left"
onblur="jadgeuserName()">
<span id="TwouserNameID" style="color: red; font-size: medium;"></span>
<br>
<br>
密码 :
<input type="password" id="passwordID" maxlength="100"
name="Pwd" onblur="">
<span id="TwopasswordID" style="color: red; font-size: medium;"></span>
<input type="submit" value="用户登录" name="" size="10%"
id="submitID" >
</form>
</body>
</html>
LoginAction为:运行的时候能够打印出System.out.println("LoginAction中已经执行!");语句的但是在return的时候就出现404了
package actions;
import com.opensymphony.xwork2.ActionSupport;
public class LoginAction extends ActionSupport{
private String name;
private String Pwd;
public String execute(){
System.out.println("LoginAction中已经执行!");
return SUCCESS;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPwd() {
return Pwd;
}
public void setPwd(String pwd) {
Pwd = pwd;
}
}
项目的布置如下:
jsp页面全部放在webRoot目录之下
希望大侠们一定要帮帮我啊,谢谢了.我始终没发现配置错在哪里
------解决方案--------------------
跟踪一下/findLover.jsp是否应该在正确的位置:
在login.jsp中加入如下语句:
<%
out.println("application.getRealPath=["+application.getRealPath("/findLover.jsp")+"]<br>");
%>
估计是你的根站点不一定是WebRoot。
------解决方案--------------------
还有一种在Action中获取URL的实际路径方法:
在execute()方法中加入:
System.out.println("/findLover.jsp="+ServletActionContext.getServletContext().getRealPath("/findLover.jsp");
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。
其他相似内容:
-
有关 CAS 证书认证的 单点登录 问题
cas框架,证书jre中可以查看到证书,开启了ssl ,修改hosts为sso.wsria.com
输入https:\\sso.w...
-
后缀名问题
我写了一个登陆用的htmL页面 名字就叫:logion.html但是那个图标就是不变成浏览器的样子是一个未知图标,请问要怎么样解...
-
请问如何用java代码实现 ,重启tomcat6啊
请问如何用java代码实现 ,重启tomcat6啊
公司领导有个需求:需要在页面上实现一个按钮来重启...
-
IIS与TOMCAT的整合,函数不正确
我的服务器是IIS+TOMCAT整合起来的,里面挂有ASP、PHP和JAVA等网站,以前一直用得好好的,但前些天删除掉...
-
关闭tomcat时出错了!!!怎么回事
息: Stopping Coyote HTTP/1.1 on http-8080
Exception in thread "ShutdownHook" java.lang.NullPo...
-
struts2 Exception 求解答
严重: Exception starting filter strutsdangdang
java.lang.ClassNotFoundException: org.apache.str...
-
tomcat启动后无法访问localhost
2011-10-10 16:12:08 org.apache.catalina.core.AprLifecycleListener init
信息: The Apache To...
-
JSP页面和Servlet页面不在同一个目录下,JSP页面通过表单的action如何跳转到servlet页面
我的项目的名称是Exercise,然后在src目录...
-
Apache下的DocumentRoot目录指定
apache配置文件已经指定了,但是日志里面还是报错。
<VirtualHost *:8080>
DocumentRoot /var/...
-
如何让外网访问虚拟机上的apache
apache安装在虚拟机上,通过局域网的ip地址能够在本机上对它进行访问,但是在外网就不能通过外网的I...