servlets如何在java中获取当前国家名称?
我想用java获取当前的国家名称。我使用这个代码
private HttpServletRequest request;
Locale currentCountry = request.getLocale();
System.out.println(currentCountry.getDisplayCountry());
但是它是通过一个NullPointerException实现的,比如:java.lang.NullPointerException
。在二线。任何人都请帮助我
# 1 楼答案
这段代码不足以说明为什么会得到空指针。我假设您在服务器端使用servlet