Java – unable to resolve HttpServletRequest

I have imported the following

I want to get the preferred language browser

HttpServletRequest request = ServletActionContext.getRequest();
Locale userPreferredLocale = request.getLocale();

I got an error that HttpServletRequest could not resolve

If possible, someone can help me and give me step-by-step guidance I am not a java developer, but a Net, just fix a bug

Thank you.

Solution

javax. servlet. The HTTP package is part of the servlet API Relevant jars can be found in Java EE containers (such as sun's GlassFish) or independent servlet containers (such as Apache's Tomcat) In essence, these are Java Web servers

In order to compile the code that depends on it, you must add the servlet library to the dependency How you do this depends on the tool you use

Are you building a web application? (is the expected output a. War or. Ear file?) Whether the source is bundled with build XML (possibly ant version), any POM XML file (possibly Maven version) or any project / . Classpath file (possibly an eclipse project)?

OK, ignore what I said above To get locale in applet, I think you will use:

Locale userLocale = Locale.getDefault();

On the Java Web server, you will use request Getlocale () gets the user's locale from the HTTP request The applet runs on the client

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>