
jsp编程序的时候出现以下错误是为什么啊?
Anerroroccurredatline:24inthejspfile:/visitor.jspapplicationcannotberesolved22:public...
An error occurred at line: 24 in the jsp file: /visitor.jsp
application cannot be resolved
22: public void addPerson(String p)
23: {
24: if(application.getAttribute("person")==null)
25: application.setAttritube("person",p);
26: else
An error occurred at line: 25 in the jsp file: /visitor.jsp
application cannot be resolved
22: public void addPerson(String p)
23: {
24: if(application.getAttribute("person")==null)
25: application.setAttritube("person",p);
26: else
27: application.setAttritube("person",(String)application.getAttritube("person")+p);
28: count++;
An error occurred at line: 27 in the jsp file: /visitor.jsp
application cannot be resolved
24: if(application.getAttribute("person")==null)
25: application.setAttritube("person",p);
26: else
27: application.setAttritube("person",(String)application.getAttritube("person")+p);
28: count++;
29: }
30: } 展开
application cannot be resolved
22: public void addPerson(String p)
23: {
24: if(application.getAttribute("person")==null)
25: application.setAttritube("person",p);
26: else
An error occurred at line: 25 in the jsp file: /visitor.jsp
application cannot be resolved
22: public void addPerson(String p)
23: {
24: if(application.getAttribute("person")==null)
25: application.setAttritube("person",p);
26: else
27: application.setAttritube("person",(String)application.getAttritube("person")+p);
28: count++;
An error occurred at line: 27 in the jsp file: /visitor.jsp
application cannot be resolved
24: if(application.getAttribute("person")==null)
25: application.setAttritube("person",p);
26: else
27: application.setAttritube("person",(String)application.getAttritube("person")+p);
28: count++;
29: }
30: } 展开
展开全部
jsp页面内部定义方法也可以,页面里的java代码本身就在一个方法体里,你的public void addPerson(String p)相当于方法套嵌,但java不允许这样做,而appliction是内置对象他的作用域在jsp的方法体内,你的那个方法中不存在appliction这个对象,所以它提示你appliction cant be resolved
。
jsp中定义方法,需要注意以下几点:
1,需要使用<%! %>这样的标签包起来,这是jsp中定义变量或者方法的标志。
2,如果在方法中需要使用内置对象out时,一定要在方法的参数列表中传过来,并且要让方法跑出一个IO异常。
3,方法的范围就不要定义了,反正就是内部使用,直接使用缺省范围的就可以了。
或者你把方法声明去了内部的东西写在外面就行了。
。
jsp中定义方法,需要注意以下几点:
1,需要使用<%! %>这样的标签包起来,这是jsp中定义变量或者方法的标志。
2,如果在方法中需要使用内置对象out时,一定要在方法的参数列表中传过来,并且要让方法跑出一个IO异常。
3,方法的范围就不要定义了,反正就是内部使用,直接使用缺省范围的就可以了。
或者你把方法声明去了内部的东西写在外面就行了。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询