报错:org.apache.jasper.JasperException: /WebRoot/index.jsp(29,4) The function getCheck must be used with a prefix when a default namespace is not specifiedJSP:<%@ page language="java" import="java.util.*,java.sql.*,javax.naming.*,javax.sql.*" pageEncoding="utf-8"%>
<%@ page import="com.CheckLogin"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
request.setCharacterEncoding("utf-8");
%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>My JSP 'index.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">
--> </head>
<body bgcolor="#b0e0e6">
<c:if test="${param.iflogin=='1'}">
<jsp:useBean id="checker" class="com.CheckLogin" scope="request">
<jsp:setProperty name="user" property="username" value="${param.un}" />
<jsp:setProperty name="psw" property="password" value="${param.psw}" />
<c:if test="${checker.getCheck()}"> //这里报错
<c:set var="UserCode" value="${checker.getUser()}" scope="session"/>
<jsp:forward page="admin.jsp" />
</c:if>
</jsp:useBean>
<center>用户名或密码错误!</center>
</c:if>
<center><br><br><br><br>
<script type="text/javascript">
//<!--
function CheckForm(form)
{
for(var i=0;i<form.elements.length;i++)
if(form.elements[i].value=="")
{
alert("请填写所有的内容!");
return false;
}
return true;
}
//-->
</script>
<form action="admin_login.jsp" method="post" onsubmit="return CheckForm(this)">
用户名:<input type="text" name="un"><br> 密 码:<input type="password" name="psw">
<input type="hidden" name="iflogin" value=1>
<br><input type="submit" value="确定"> <input type="reset" value="重写">
</form>
</center>
</body>
</html>
JAVABEANpackage com;import java.util.*;
import java.sql.*;
import javax.naming.*;
import javax.sql.*;
import java.io.*;
public class CheckLogin
{
String user,psw;
int wa=0;
ResultSet rs=null;
boolean check;
public CheckLogin(String username,String password)
{
user=username;
psw=password;
}
public void setWa(int WA)
{
wa=WA;
}
public int getWa()
{
return wa;
}
public void setUser(String username)
{
user=username;
}
public String getUser()
{
return user;
}
public void setPsw(String password)
{
psw=password;
}
public String getPsw()
{
return psw;
}
public void setCheck(boolean chk)
{
check=chk;
}
public boolean getCheck()
{
check=false;
getConnect gC=new getConnect();
try{
wa=0;
String sql="Select * from SystemUser where UseCode='"+user+"'";
rs=gC.query(sql);
if(rs.next())
{
if(rs.getString("PassWords").equals(psw))
{
gC.closeConn();
check=true;
}
}
else
{
gC.closeConn();
check=false;
}
}
catch(Exception e)
{
gC.closeConn();
System.out.println(e.getMessage());
}
return check;
}
}好像是EL中不能用JAVABEAN中的方法
但是如果想要实现这个功能 应当怎么改呢?
<%@ page import="com.CheckLogin"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
request.setCharacterEncoding("utf-8");
%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>My JSP 'index.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">
--> </head>
<body bgcolor="#b0e0e6">
<c:if test="${param.iflogin=='1'}">
<jsp:useBean id="checker" class="com.CheckLogin" scope="request">
<jsp:setProperty name="user" property="username" value="${param.un}" />
<jsp:setProperty name="psw" property="password" value="${param.psw}" />
<c:if test="${checker.getCheck()}"> //这里报错
<c:set var="UserCode" value="${checker.getUser()}" scope="session"/>
<jsp:forward page="admin.jsp" />
</c:if>
</jsp:useBean>
<center>用户名或密码错误!</center>
</c:if>
<center><br><br><br><br>
<script type="text/javascript">
//<!--
function CheckForm(form)
{
for(var i=0;i<form.elements.length;i++)
if(form.elements[i].value=="")
{
alert("请填写所有的内容!");
return false;
}
return true;
}
//-->
</script>
<form action="admin_login.jsp" method="post" onsubmit="return CheckForm(this)">
用户名:<input type="text" name="un"><br> 密 码:<input type="password" name="psw">
<input type="hidden" name="iflogin" value=1>
<br><input type="submit" value="确定"> <input type="reset" value="重写">
</form>
</center>
</body>
</html>
JAVABEANpackage com;import java.util.*;
import java.sql.*;
import javax.naming.*;
import javax.sql.*;
import java.io.*;
public class CheckLogin
{
String user,psw;
int wa=0;
ResultSet rs=null;
boolean check;
public CheckLogin(String username,String password)
{
user=username;
psw=password;
}
public void setWa(int WA)
{
wa=WA;
}
public int getWa()
{
return wa;
}
public void setUser(String username)
{
user=username;
}
public String getUser()
{
return user;
}
public void setPsw(String password)
{
psw=password;
}
public String getPsw()
{
return psw;
}
public void setCheck(boolean chk)
{
check=chk;
}
public boolean getCheck()
{
check=false;
getConnect gC=new getConnect();
try{
wa=0;
String sql="Select * from SystemUser where UseCode='"+user+"'";
rs=gC.query(sql);
if(rs.next())
{
if(rs.getString("PassWords").equals(psw))
{
gC.closeConn();
check=true;
}
}
else
{
gC.closeConn();
check=false;
}
}
catch(Exception e)
{
gC.closeConn();
System.out.println(e.getMessage());
}
return check;
}
}好像是EL中不能用JAVABEAN中的方法
但是如果想要实现这个功能 应当怎么改呢?
解决方案 »
- Google Adwords API 开发 基础问题
- map如何通过value获得key吗
- hibernate使用求助
- 请问我这样使用cookie好不好?
- 一个奇怪或者低能的问题:遵守http协议进行通讯时候,是否服务器一定必须先收后发,客户端必须先发后收?
- java中测试可以,为什么JSP中使用jdom执行完没有往xml添加数据?
- 请问在pdf里面怎么样可以打开一个窗口,就相当于javascript中的window.open功能
- 数据库JAVA和ACCESS
- 求一方法,高分相送(特急!)
- 关于汉字的问题~请赐教
- struts action添加数据入库mysql出现乱码
- 初学JSP,不知道该怎么学。希望各位高人指教一下该怎么学。
Checker checker = new Checker();
// 其它的调用
reques.setAttribute("checker",checker);
%>
所以我能不能不用JAVA脚本呢?
在JSP的EL中访问get开头的方法,可以用这种形式,得到的是checker.getCheck()的结果