|
1 login.jsp
[php]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ page contentType="text/html;charset=gb2312" language="java"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB2312">
<title><bean:message key="app.title"/></title>
<script language="javascript">
function login(loginForm)
{
if(document.loginForm.username.value == "")
{
alert("用户名不能为空");
loginForm.username.focus();
return false;
}
else if(document.loginForm.password.value == "")
{
alert("密码不能为空!!");
loginForm.password.focus();
return false;
}
else
{
return true;
}
}
</script>
</head>
<body>
<html:errors/>
<!--<form name="loginForm" method="post" action="hello.jsp" onSubmit="return login(this)">-->
<html:form name="loginForm" action="hello.jsp" method="post" onSubmit="return login(this)">
<table>
<tr>
<!--<td><div align="right">用户名:</div></td>-->
<!--<td><input type="text" name="username"></td>-->
<td><bean:message key="app.username"/>:</td>
<td><html:text property="username"/></td>
</tr>
<tr>
<!--<td><div align="right">密nbsp;nbsp;码:</div></td>-->
<!--<td><input type="password" name="password"></td>-->
<td><bean:message key="app.password"/>:</td>
<td><html:password property="password"/></td>
</tr>
<tr>
<td></td>
<!--<td><input type="submit" name="submit" value="提交"></td>-->
<td><html:submit/></td>
</tr>
</table>
//</form>
</html:form>
</body>
</html>
[/php]
2 hello.jsp
[php]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib uri="WEB-INF/struts-bean.tld" prefix="bean"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title><bean:message key="app.title"/></title>
</head>
<body>
<!--<b>傲雪寒梅:<%=request.getParameter("username")%></b>-->
<b><bean:message key="app.hello"/>:<%=request.getParameter("username")%></b>
</body>
</html>
[/php]
3 loginerror.jsp
[php]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title><bean:message key="app.title"/></title>
</head>
<body>
<b><bean:message key="app.loginerror"/>
<a href="login.jsp"><bean:message key="app.loginagain"/></a></b>
</body>
</html>
[/php]
但是却出现org.apache.jasper.JasperException: /test/login.jsp(35,0) Attribute onSubmit invalid for tag form according to TLD
请大家指点了 |
|