Tag Archives: request.getContextPath() error

[Solved] The method getContextPath() from the type HttpServletRequest refers to the missing type String

Error: “The method getContextPath() from the type HttpServletRequest refers to the missing type String”

Solution: See if the project’s jre is different from your local name (the jre version or the name is different will cause this problem).

Specific operation:

    1. Right-click the project-Build Path-Configure Build Path, under the Libraries option, you will find an error jre Libraries, remove it.

    2. Then right-click the project-Build Path-Add Library, select JRE System Library, select Workspace defaulr JRE (jdk1.6) (the JDK has been successfully installed and configured before), and then Finish.

Note: For your own experience, you must also check whether the environment variable configuration is correct, and then restart Eclipse and recompile the program clear.

1. Open My Computer-Properties-Advanced-Environment Variables 

2. New system variables JAVA_HOME and CLASSPATH 
Variable name: JAVA_HOME 
Variable value: C:\Program Files\Java\jdk1.7.0
Variable name: CLASSPATH 
Variable value: .;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar;

3. Select the environment variable named "Path" in "System Variables", double-click the variable, add the absolute path of the bin directory in the JDK installation path to the value of the Path variable, and use half-width semicolons and existing The path is separated. 
Variable name: Path 
Variable value: ;%JAVA_HOME%\bin;%JAVA_HOME%\jre\bin;
This is the java environment configuration. After the configuration is completed, start eclipse directly, it will automatically complete the java environment configuration