代码如下,劳烦给为看看且解答则个
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
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 'MyJsp.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">
-->
<style type="text/css">
p{ color:#00C; font-size: xx-large;}
input{ font-family: "微软雅黑"}
.loginT{ color:#999; border-color:#000; width:200px; height:35px;}
.loginB{ border-color:#000; color:#00C; width:55px; height:40px;}
</style>
<script language="javascript">
function clearU(){
var a=document.getElementsByClassName("loginT");
a[0].value="";
}
function clearP(){
var a=document.getElementsByClassName("loginT");
a[1].value="";
}
</script>
</head>
<body>
<center>
<p>登录页面</p>
<form action="#" id="sub" method="post">
<input type="text" value="用户名" name="username" class="loginT" onfocus="clearU()" /><br/><br/>
<input type="text" value="密码" name="passwd" class="loginT" onfocus="clearP()"/><br/><br/>
<input type="submit" value="登录" class="loginB"/> <input type="button" value="取消" class="loginB"/>
</form>
</center>
<%@ page contentType="text/html;charset=utf8"%>
<%String username=request.getParameter("username");%>
<%=username %><%-- 这里获得表单username的值是空值--%>
</body>
</html>
2 个解决方案
#1
<form action="#" id="sub" method="post">
改为
<form action="" id="sub" method="post">
应该是可以的
改为
<form action="" id="sub" method="post">
应该是可以的
#2
多谢已经解决了
#1
<form action="#" id="sub" method="post">
改为
<form action="" id="sub" method="post">
应该是可以的
改为
<form action="" id="sub" method="post">
应该是可以的
#2
多谢已经解决了