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

同一个页面将js的值传回给java

<%@ page language="java" contentType="text/html; charset=gbk"
??? pageEncoding="gbk"%>
<!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=gbk">
<title>Insert title here</title>
<script type="text/javascript"? language="javascript">

function? jstest()
{
?? var s="你的值";
???? window.status="页面已加载";
?? //? alert( "haha ");
?document.forms["form1"].test.value="dhkfdjfdjhfjd";
?document.forms["form1"].submit();
}
</script>
</head>
<body onload="jstest()">
<form name="form1" method="post" action="value.jsp" >
<input type="hidden" name="test"? />
</form>
jsp<%
?String s=new String();
? String st=request.getParameter("test");?
?out.print(st);
%>
</body>
</html>

?

?

或者用AJax技术........