用eclipse编写jsp为什么调用方法错误

<%@page contentType="text/html;charset=GB2312"%>
<%@page import="java.util.*"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>



Insert title here



<%!
TreeSet dictionary = new TreeSet ();
public void addWord(String s){
String word[]=s.split (" ");
for(int i=0;i dictionary.add(word[i]);
}
}
%>
<%
String str=request.getParameter("word");
addWord(str);
Iteratorte=dictionary.iterator();
while(te.hasNext()){
String word=te.next();
out.print(" "+word);
}
%>



就是上面的 new TreeSet ();总是提示错误也不知道是什么原因 代码简单也是照着书上打的 有大牛愿意看看指导一下看看问题出在哪里吗?

你for循环下的{}真的没有打错吗?

有没有中文字符混入呀

可以打断点,自己一一排查

public void addWord(String s){

jsp中不能再定义一个方法