在页面提交的时候有验证,如果验证不成功就返回录入页面,这时候再点击提交就会发现提交的路径不对
比如开始的时候提交的路径是"/reply/user/getPassword.action",其中reply是工程名称,user是工程下面的一个子文件夹,提交的页面也是在user下面,当用户提交(输入不合法),再返回录入页面,这时候页面显示是正常的,但action的路径已经变成了“/reply/getPassword.action”,中间的user没了,这时候再点击提交就出问题了,路径不对,这是怎么回事。大家帮帮忙
struts.xml的配置是这样的:
<package name="package2" extends="struts-default">
<action name="getPassword" class="forgetPassword" method="sendPassword">
<result>/msg.jsp</result>
<result name="input">/user/getPassword.jsp</result>
</action>
</package>
在线等待解答。谢谢
比如开始的时候提交的路径是"/reply/user/getPassword.action",其中reply是工程名称,user是工程下面的一个子文件夹,提交的页面也是在user下面,当用户提交(输入不合法),再返回录入页面,这时候页面显示是正常的,但action的路径已经变成了“/reply/getPassword.action”,中间的user没了,这时候再点击提交就出问题了,路径不对,这是怎么回事。大家帮帮忙
struts.xml的配置是这样的:
<package name="package2" extends="struts-default">
<action name="getPassword" class="forgetPassword" method="sendPassword">
<result>/msg.jsp</result>
<result name="input">/user/getPassword.jsp</result>
</action>
</package>
在线等待解答。谢谢
<action name="getPassword" class="forgetPassword" method="sendPassword">
<result>/msg.jsp </result>
<result name="input">/user/getPassword.jsp </result>
</action>
</package>
红色部分应该用user吧
<%@taglib prefix="s" uri="/struts-tags"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<html>
<head>
<base href="<%=basePath%>">
<title>页面标题</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta>
<link rel="shortcut icon" href="image/favicon.ico" />
<link rel="icon" type="image/gif" href="image/favicon.gif"></link>
<script type="text/javascript" src="js/btn.js"></script>
<link href="css/css.css" rel="stylesheet" type="text/css" media="screen"/>
</head>
<body> <table width="980px" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td colspan="2"><jsp:include page="../top.jsp" flush="true"/></td>
</tr>
<tr>
<td width="220" valign="top"><jsp:include page="../loginleft.jsp" flush="true"/></td>
<td width="811" valign="top" align="center">
<s:form action="getPassword" theme="simple" method="post" name="form1">
<table width="90%" border="0" cellpadding="0" cellspacing="0" class="text">
<tr >
<td colspan="2" class="title1" background="image/bg_top.jpg"> 密码找回</td>
</tr>
<tr >
<td colspan="2" class="warning" ><s:fielderror/>
<s:actionerror/>
</td>
</tr>
<tr >
<td colspan="2" class="warning" > 请正确填写您登录所有用的邮箱,系统将发送密码到您指定的邮箱地址</td>
</tr>
<tr>
<td width="17%" align="left">请输入您的ID</td>
<td width="83%" align="left"><s:textfield name="user.userId" cssClass="input1" onblur="this.className='input1'" onfocus="this.className='input1-bor'" size="30"/></td>
</tr>
<tr>
<td align="left">邮箱选择</td>
<td align="left"><s:radio list="#{'0':'发送至ID邮箱','1':'发送至备用邮箱'}" name="emailType"></s:radio>
</td>
</tr>
<tr>
<td colspan="2" align="center"></td>
</tr>
</table>
<table ><tr><td>
<s:submit value="发送"/></td></tr></table>
</s:form>
</td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td colspan="2"><%@ include file="../foot.jsp"%></td>
</tr>
</table> </body>
</html>
<package name="package2" extends="struts-default" namespace="/user">
struts2不熟
只是建议一下,加个名称空间试试
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%> 把这个去了
不会出现你所说的情况
加这个试试。
user不见了 说明你的返回路径出了问题 应该是到reply/user/下面,而你却到了reply/下面。
请把你的页面提交的过程 和 错误页面转向的过程说的详细点
<action name="getPassword" class="reply.user.getPassword" method="sendPassword">
应该就可以了,也就是class用全路径