注册 登录
编程论坛 J2EE论坛

Myeclipse软件中的jsp问题!

矿泉水wz 发布于 2007-11-08 15:28, 720 次点击


Myeclipse软件中的jsp问题!

请教高手:::::::::::::::::::
用Myeclipse软件中的jsp,jsp中的<form>标签为什么不能给name属性?(给就会错)
如果我想在同页面的"脚本"中得到<form>中的值,应该怎样得到?

4 回复
#2
netstriker2007-11-08 15:38

用dom来做

<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'test.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<script type="text/javascript">
function get()
{
var form = document.getElementById("myform");
alert(form.name);
}
</script>
</head>

<body>
<form id="myform" action="" method="POST" name="www.it.com.cn"></form> //但是我用name的时候没有出错啊
<button onClick="get()">Get</button>
</body>
</html>

#3
矿泉水wz2007-11-08 15:47
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">

这些是干什么用的???
#4
netstriker2007-11-08 15:49
   没有什么用的。myEclipse自动生成,你可以删掉它,不会影响运行的
#5
矿泉水wz2007-11-08 15:51
袄...我用的是5.0版本的.....没看到!
谢谢!!!!
1