日期:2014-05-16  浏览次数:20654 次

ajax验证+iframe提交
<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title></title>
<script type="text/javascript">
	var xmlhttp;
	function createXmlHttpReq() {
		if (window.ActiveXObject) {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} else if (window.XMLHttpRequest) {
			xmlhttp = new XMLHttpRequest();
		}
	}
	function createAcct() {
		createXmlHttpReq();
		xmlhttp.open("GET",'<c:url value="/fundAcct.do"/>',false);
		xmlhttp.onreadyStateChange = handleRes;
		xmlhttp.send(null);
	}
	function handleRes() {
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
			var div = document.createElement("div");
			div.style.width=document.documentElement.offsetWidth-22;
			div.style.height=document.documentElement.offsetHeight-22;
			div.style.position="absolute";
			div.style.top="0";
			div.style.left="0";
			div.style.background="#D4D4D4";
			div.style.filter = "alpha(opacity=80)";
			document.body.appendChild(div);
			document.getElementById("result").innerHTML = xmlhttp.responseText;
		}
	}
</script>
</head>
<body bgcolor="#EBEEF7">
<c:if test="${empty RES}">
	<c:if test="${not empty ERR}">
		<div><font style="font-weight: bold;" color="red"><c:out value="${ERR}"/></font></div>
	</c:if>
	<form id="myForm" action="<c:url value="/fundAcct.do"/>" method="post" target="targetFrame">
		编号:<input type="text" tabindex="0" name="fundNo" value="<c:out value="${fundAcctDTO.fundNo }"/>"/><br/>
		名称:<input type="text" tabindex="1" name="fundName" value="<c:out value="${fundAcctDTO.fundName }"/>"/><br/>
		<input type="submit" value="提交" id="sub">
	</form>
	<hr/><br/>
	<iframe name="targetFrame" src="/blank.screen" frameborder="0"></iframe>
	<script type="text/javascript">
		parent.document.all.targetFrame.style.height=document.documentElement.scrollHeight;
		parent.document.all.targetFrame.style.width=document.documentElement.scrollWidth;
	</script>
</c:if>
<c:if test="${not empty RES}">
	<table>
		<tr><td>结果</td></tr>
		<c:if test="${empty account}">
			<tr><td>无结果</td></tr>
		</c:if>
		<c:if test="${not empty account}">
			<c:forEach items="${account}" var="acc">
				<tr><td><c:out value="${acc}"/></td></tr>
			</c:forEach>
		</c:if>
	</table>	
</c:if>
</body>
</html>



import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.paic.pafa.app.lwc.service.databinding.BindException;
import com.paic.pafa.app.web.servlet.ModelAndView;
import com.paic.pafa.app.web.servlet.mvc.SimpleFormController;
import com.pingan.nts.extrading.invest.dto.FundAcctDTO;

public class FundAcctController extends SimpleFormController {

	private static final Log LOG = LogFactory.getLog(FundAcctController.class);

	@Override
	protected ModelAndView onSubmit(HttpServletRequest request,
			HttpServletResponse response, Object command, BindException errors)
			throws Exception {
		response.setContentType("text/html; charset=utf-8");
		LOG.info("ENTER.....");
		FundAcctDTO fundAcctDTO = (FundAcctDTO)command;
		Map<String, Object> model =