The field HttpServlet.lStrings is not visible


最近刚刚开始学习java web 在如下代码的时候提示出了这个错误,我ctrl+shift+o也木有用!代码是书上抄的。求各位java同学解释下。
clipboard.png


 package chapter4;


import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class MethodTest extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req,HttpServletResponse resp) throws ServletException,IOException
    {
        String method = req.getMethod();
        PrintWriter out=resp.getWriter();
        //out.println(method);
        if(method.equals("GET"))
        {
            doGet(req,resp);
        }
        else if(method.equals("POST"))
        {
            doPost(req,resp);
        }
        else
        {
            String errMsg=lStrings.getString("http.method_not_implemented");
        }
    }
}

java javaweb servlet

拉格朗余项 9 years, 6 months ago

lStrings是HttpServlet类下面的一个private属性,无法被子类调用,关于private,protected,(default),public的知识,请参考Thinking in Java中的Access Control一章。

藤堂末莉丸 answered 9 years, 6 months ago

Your Answer