以下是一堆错误(无法解决,希望得到帮助~~~)An error occurred at line: 12 in the jsp file: /reg_action.jsp
LengthCheck.String cannot be resolved to a type
9: <body>
10:
11: <%
12: public LengthCheck(String str,int MinLength,int MaxLength)
13: {
14: return((str.length>=MinLength)&&(str.length<=MaxLength));
15: }
An error occurred at line: 12 in the jsp file: /reg_action.jsp
Syntax error on token "(", . expected
9: <body>
10:
11: <%
12: public LengthCheck(String str,int MinLength,int MaxLength)
13: {
14: return((str.length>=MinLength)&&(str.length<=MaxLength));
15: }
An error occurred at line: 12 in the jsp file: /reg_action.jsp
Illegal modifier for the variable str; only final is permitted
9: <body>
10:
11: <%
12: public LengthCheck(String str,int MinLength,int MaxLength)
13: {
14: return((str.length>=MinLength)&&(str.length<=MaxLength));
15: }
An error occurred at line: 12 in the jsp file: /reg_action.jsp
Syntax error on token ",", ; expected
9: <body>
10:
11: <%
12: public LengthCheck(String str,int MinLength,int MaxLength)
13: {
14: return((str.length>=MinLength)&&(str.length<=MaxLength));
15: }
An error occurred at line: 12 in the jsp file: /reg_action.jsp
Syntax error on token ",", ; expected
9: <body>
10:
11: <%
12: public LengthCheck(String str,int MinLength,int MaxLength)
13: {
14: return((str.length>=MinLength)&&(str.length<=MaxLength));
15: }
An error occurred at line: 12 in the jsp file: /reg_action.jsp
Syntax error on token ")", ; expected
9: <body>
10:
11: <%
12: public LengthCheck(String str,int MinLength,int MaxLength)
13: {
14: return((str.length>=MinLength)&&(str.length<=MaxLength));
15: }
An error occurred at line: 33 in the jsp file: /reg_action.jsp
Cannot invoke indexOf(char) on the primitive type char
30: for(int i=0;i<UserName.length();i++)
31: {
32: char temp=UserName.charAt(i);
33: if(!((temp>='a'&&temp<='z')||(temp>='A'&&temp<='Z')||(temp=='_')||(temp.indexOf(temp)!=-1)))
34: Error+="用户名必须由数字、字母和下划线构成<br>";
35: allOk=false;
36: }
An error occurred at line: 38 in the jsp file: /reg_action.jsp
The method LengthCheck(String, int, int) is undefined for the type reg_005faction_jsp
35: allOk=false;
36: }
37:
38: if(!LengthCheck(UserName,4,20))
39: {
40: Error+="请检查用户名长度<br>";
41: allOk=false;
An error occurred at line: 50 in the jsp file: /reg_action.jsp
sex cannot be resolved
47: allOk=false;
48: }
49: if(Sex.equals("男"))
50: sex="0";
51: else if(Sex.equals("女"))
52: sex="1";
53: else
An error occurred at line: 52 in the jsp file: /reg_action.jsp
sex cannot be resolved
49: if(Sex.equals("男"))
50: sex="0";
51: else if(Sex.equals("女"))
52: sex="1";
53: else
54: sex="2";
55: if(Password.length()==0)
An error occurred at line: 54 in the jsp file: /reg_action.jsp
sex cannot be resolved
51: else if(Sex.equals("女"))
52: sex="1";
53: else
54: sex="2";
55: if(Password.length()==0)
56: {
57: Error+="请设置密码<br>";
An error occurred at line: 61 in the jsp file: /reg_action.jsp
The method LengthCheck(String, int, int) is undefined for the type reg_005faction_jsp
58: Password="";
59: allOk=false;
60: }
61: if(!LengthCheck(Password,6,12))
62: {
63: Error+="密码长度应该在6-12位间<br>";
64: allOk=false;
An error occurred at line: 66 in the jsp file: /reg_action.jsp
The method LengthCheck(String, int, int) is undefined for the type reg_005faction_jsp
63: Error+="密码长度应该在6-12位间<br>";
64: allOk=false;
65: }
66: if((!LengthCheck(PwdConfirm,6,12))|(!Password.equals(PwdConfirm)))
67: {
68: Error+="请重新确认密码<br>";
69: PwdConfirm="";
Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:423)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:316)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:294)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:281)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
LengthCheck.String cannot be resolved to a type
9: <body>
10:
11: <%
12: public LengthCheck(String str,int MinLength,int MaxLength)
13: {
14: return((str.length>=MinLength)&&(str.length<=MaxLength));
15: }
An error occurred at line: 12 in the jsp file: /reg_action.jsp
Syntax error on token "(", . expected
9: <body>
10:
11: <%
12: public LengthCheck(String str,int MinLength,int MaxLength)
13: {
14: return((str.length>=MinLength)&&(str.length<=MaxLength));
15: }
An error occurred at line: 12 in the jsp file: /reg_action.jsp
Illegal modifier for the variable str; only final is permitted
9: <body>
10:
11: <%
12: public LengthCheck(String str,int MinLength,int MaxLength)
13: {
14: return((str.length>=MinLength)&&(str.length<=MaxLength));
15: }
An error occurred at line: 12 in the jsp file: /reg_action.jsp
Syntax error on token ",", ; expected
9: <body>
10:
11: <%
12: public LengthCheck(String str,int MinLength,int MaxLength)
13: {
14: return((str.length>=MinLength)&&(str.length<=MaxLength));
15: }
An error occurred at line: 12 in the jsp file: /reg_action.jsp
Syntax error on token ",", ; expected
9: <body>
10:
11: <%
12: public LengthCheck(String str,int MinLength,int MaxLength)
13: {
14: return((str.length>=MinLength)&&(str.length<=MaxLength));
15: }
An error occurred at line: 12 in the jsp file: /reg_action.jsp
Syntax error on token ")", ; expected
9: <body>
10:
11: <%
12: public LengthCheck(String str,int MinLength,int MaxLength)
13: {
14: return((str.length>=MinLength)&&(str.length<=MaxLength));
15: }
An error occurred at line: 33 in the jsp file: /reg_action.jsp
Cannot invoke indexOf(char) on the primitive type char
30: for(int i=0;i<UserName.length();i++)
31: {
32: char temp=UserName.charAt(i);
33: if(!((temp>='a'&&temp<='z')||(temp>='A'&&temp<='Z')||(temp=='_')||(temp.indexOf(temp)!=-1)))
34: Error+="用户名必须由数字、字母和下划线构成<br>";
35: allOk=false;
36: }
An error occurred at line: 38 in the jsp file: /reg_action.jsp
The method LengthCheck(String, int, int) is undefined for the type reg_005faction_jsp
35: allOk=false;
36: }
37:
38: if(!LengthCheck(UserName,4,20))
39: {
40: Error+="请检查用户名长度<br>";
41: allOk=false;
An error occurred at line: 50 in the jsp file: /reg_action.jsp
sex cannot be resolved
47: allOk=false;
48: }
49: if(Sex.equals("男"))
50: sex="0";
51: else if(Sex.equals("女"))
52: sex="1";
53: else
An error occurred at line: 52 in the jsp file: /reg_action.jsp
sex cannot be resolved
49: if(Sex.equals("男"))
50: sex="0";
51: else if(Sex.equals("女"))
52: sex="1";
53: else
54: sex="2";
55: if(Password.length()==0)
An error occurred at line: 54 in the jsp file: /reg_action.jsp
sex cannot be resolved
51: else if(Sex.equals("女"))
52: sex="1";
53: else
54: sex="2";
55: if(Password.length()==0)
56: {
57: Error+="请设置密码<br>";
An error occurred at line: 61 in the jsp file: /reg_action.jsp
The method LengthCheck(String, int, int) is undefined for the type reg_005faction_jsp
58: Password="";
59: allOk=false;
60: }
61: if(!LengthCheck(Password,6,12))
62: {
63: Error+="密码长度应该在6-12位间<br>";
64: allOk=false;
An error occurred at line: 66 in the jsp file: /reg_action.jsp
The method LengthCheck(String, int, int) is undefined for the type reg_005faction_jsp
63: Error+="密码长度应该在6-12位间<br>";
64: allOk=false;
65: }
66: if((!LengthCheck(PwdConfirm,6,12))|(!Password.equals(PwdConfirm)))
67: {
68: Error+="请重新确认密码<br>";
69: PwdConfirm="";
Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:423)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:316)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:294)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:281)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
楼主【javascriptphp】截止到2008-07-26 14:45:03的历史汇总数据(不包括此帖):
发帖的总数量:1 发帖的总分数:0 每贴平均分数:0
回帖的总数量:0 得分贴总数量:0 回帖的得分率:0%
结贴的总数量:0 结贴的总分数:0
无满意结贴数:0 无满意结贴分:0
未结的帖子数:1 未结的总分数:0
结贴的百分比:0.00 % 结分的百分比:---------------------
无满意结贴率:---------------------无满意结分率:---------------------
如何结贴请参考这里:http://topic.csdn.net/u/20080501/09/ef7ba1b3-6466-49f6-9d92-36fe6d471dd1.html
为啥要这样写?
jsp页面运行时都会被转成servlet,页面里面的脚本会称为service()方法的一部分,所以,不能象你那样定义方法
改成<%! 方法定义 %>,这样定义的方法就是在jsp生成的servlet类中了。38行那个错误是你indexOf()方法的参数传错了,这个方法是返回字符在目标字符串中的索引,所以传的参数应该是字符串,
用来判断字符串中是否包含某个字母,不知道你这个判断什么,前面的判断是否为字母,Character类提供了静态方法
Character.isLetter(char)用来判断某个字符是不是字母,Character.isLetterOrDigit(char)判断某个字符是不是字母或数字38行和第12行一样,12行的方法定义有问题,所以38行调用它也不对50,52,54行是sex无法解析,不知道是你露定义了,还是其他的问题,没有完整 的代码,无法判断61,66行和38行的问题一样,还是那个方法的问题
在 <%! %> 里面是允许的。
请参看 2楼的你建议,把这部分代码独立出来
<!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=gb2312">
<title>注册判断</title>
</head><body> <%
public LengthCheck(String str,int MinLength,int MaxLength)
{
return((str.length>=MinLength)&&(str.length<=MaxLength));
}
String UserName=request.getParameter("UserName");
String NickName=request.getParameter("NickName");
String Sex=request.getParameter("Sex");
String Password=request.getParameter("Password");
String PwdConfirm=request.getParameter("PwdConfirm");
String Question=request.getParameter("Question");
String Answer=request.getParameter("Answer");
String Email=request.getParameter("Email");
String Error=new String(); %>
<%
boolean allOk=true;
String Number="0123456789";
for(int i=0;i<UserName.length();i++)
{
char temp=UserName.charAt(i);
if(!((temp>='a'&&temp<='z')||(temp>='A'&&temp<='Z')||(temp=='_')||(temp.indexOf(temp)!=-1)))
Error+="用户名必须由数字、字母和下划线构成<br>";
allOk=false;
} if(!LengthCheck(UserName,4,20))
{
Error+="请检查用户名长度<br>";
allOk=false;
}
if(NickName.length()==0)
{
Error+="请填写昵称<br>";
NickName="";
allOk=false;
}
if(Sex.equals("男"))
sex="0";
else if(Sex.equals("女"))
sex="1";
else
sex="2";
if(Password.length()==0)
{
Error+="请设置密码<br>";
Password="";
allOk=false;
}
if(!LengthCheck(Password,6,12))
{
Error+="密码长度应该在6-12位间<br>";
allOk=false;
}
if((!LengthCheck(PwdConfirm,6,12))|(!Password.equals(PwdConfirm)))
{
Error+="请重新确认密码<br>";
PwdConfirm="";
allOk=false;
}
if(Question.length()==0)
{
Error+="请选择密码提示问题<br>";
Question="";
allOk=false;
}
if(Answer.length()==0)
{
Error+="请填写密码问题答案<br>";
Answer="";
allOk=false;
}
if(Email.indexOf('@')<=0)
{
Error+="邮件地址填写不正确,请重新填写<br>";
Email="";
allOk=false;
}
if(allOk)
{
UserName=(String)session.getAttribute("UserName");
NickName=(String)session.getAttribute("NickName");
Sex=(String)session.getAttribute("Sex");
Password=(String)session.getAttribute("Password");
PwdConfirm=(String)session.getAttribute("PwdConfirm");
Question=(String)session.getAttribute("Question");
Answer=(String)session.getAttribute("Answer");
Email=(String)session.getAttribute("Email");
%>
<jsp:forward page="reg22.jsp"/>
<%
}
else
{ Error=(String)session.getAttribute("Error");
%>
<jsp:forward page="reg_error.jsp"/>
<%
}
%>
</body>
</html>
以上是reg_action.jsp的完整文件