我的注册页面( empregistration.jsp )会自动转发到( success.jsp )如何停止此操作我只想在按下提交按钮时将其转发< / p>
empregistration.jsp
<%@ page language ="java" contentType ="text/html; charset=ISO-8859-1" pageEncoding ="ISO-8859-1"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%@ taglib uri="/struts-dojo-tags" prefix="sx" %>
<html>
<head><meta http-equiv="Refresh" content="30;URL=emplogin.action">
<sx:head/>
<script type="text/javascript" src ="script.js"></script>
</head>
<body>
<div align="center"> <h1 style="color: red"> ENPLOYEE REGISTRATION FORM</h1>
<s:form action="emplogin" method="post" >
<s:textfield name="firstname" label="Employee Firstname"/>
<s:textfield name ="lastname" label ="Last name"/>
<s:textfield name ="id" label="Id"/>
<s:radio name ="gender" list="{'male', 'female'}" label = "Gender"/>
<sx:datetimepicker name="dob" displayFormat="dd-MMM-yyyy" label="DOB"></sx:datetimepicker>
<s:radio name ="maritalstatus" list="{'singale','married'}" label="Marital Status" />
<s:textfield name ="email" label ="Email"/>
<sx:datetimepicker name ="joiningdate" displayFormat="dd-MMM-yyyy" label="Joining Date"></sx:datetimepicker>
<s:textfield name= "designation" label = "Designation"/>
<s:textarea name ="address" label ="Address" />
<s:textfield name = "country" label ="Country" />
<s:textfield name ="state" label = "State" />
<s:textfield name ="city" label ="City"/>
<s:textfield name ="pincode" label ="Pincode"/>
<s:textfield name ="mobileno" label="Mobile No"/>
<s:select name ="groups" list="{'group 1', 'group 2', 'group 3'}" label ="Group" cssStyle="{width:184px"/>
<tr><td> </td></tr>
<tr>
<td> </td>
<s:submit align="center"></s:submit>
</s:form>
</div>
</body>
</html>
答案 0 :(得分:1)
<meta http-equiv="Refresh" content="30;URL=emplogin.action">
empregistration.jsp
中的此标记会刷新页面。
这可能是您的代码中的问题。在元标记中,您已将网址指定为empLogin.action
。当页面刷新时,它会自动调用emplogin.action
并将您重定向到success.jsp
。
从jsp中删除此标记。
答案 1 :(得分:1)
这是因为元标记
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
将其从您的网页中删除即可使用。
答案 2 :(得分:-2)
但是现在提交日期按钮不是以正确形式提交您的详细信息的方式。
你可以用一个锚标签代替提交按钮
这里的代码是:
<a onclick="emplogin()">Login</a>
并将javascript放在头部::
<script type="text/javascript">
function emplogin()
{
document.getElementById('myform').submit();
}
</script>
并设置一个id =&#34; myform&#34;你的形式如:
<form id="myform">
</form>