编译错误:找不到符号,符号:类JSPWriter,location:class Converter

时间:2015-12-29 20:29:14

标签: java compiler-errors cannot-find-symbol

我是Java的新手,只是想编译一个类。

import javax.servlet.jsp.tagext.*;
import javax.servlet.jsp.tagext.BodyTagSupport;
import javax.servlet.jsp.tagext.BodyContent;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.*;


public class Converter extends BodyTagSupport{

    private String _to;

    public String getTo() {
        return _to;
    }   

    public void setTo(String to) {
        _to = to;
    }


    public int doAfterBody(){

    try {
        BodyContent bc = getBodyContent();
        JSPWriter out = bc.getEnclosingWriter();
        double result = 0.0;
        if(_to.equals("F")) {
            result = toFahrenheit(Double.parseDouble(bc.getString()));
        } else {
            result = toKelvin(Double.parseDouble(bc.getString()));  
        }
        out.write("Resultado: " + result);

    } catch(Exception E) {

    }   

        return EVAL_PAGE; //tells servlet container to process rest of JSP page.
    }

    private double toFahrenheit(double c){
        return 32.0 + (c*1.8);
    }

    private double toKelvin(double c){
        return 273.0 + c;
    }

编译器错误是

  

找不到符号,符号:类JSPWriter,location:class Converter

我不知道为什么会收到此错误,所以请帮帮我。

我已经将servlet-api.jar和jsp-api.jar添加到了CLASSPATH。

1 个答案:

答案 0 :(得分:1)

Java区分大小写。变化

JSPWriter out = bc.getEnclosingWriter();

JspWriter out = bc.getEnclosingWriter();