开发者

request.setCharacterEncoding("UTF-8") wrong when going to myEclipse from JBuilder2008

When working with JBuilder2008 my project would build successfully. I changed to MyEclipse and found the following issue:

request.setCharacterEncoding(&quo开发者_开发技巧t;UTF-8"); has got a red line below setCharacterEncoding and it has below problem message:

The method setCharacterEncoding(String) is undefined for the type HttpServletRequest

Could you tell me what shall I do?


I think that the problem is that your Eclipse is configured to use an older version of the servlet APIs; see this forum post. (Right at the end.) The method is certainly present in the Java Servlet 2.4 APIs.

(FWIW, I pick up my Java Servlet APIs via an explicit Maven dependency, so I'm not hostage to the default version implied by my IDE settings.)


Inside MyEclipse IDE, please add 'javaee.jar' in your Project's build-path. This will solve your mentioned error about "request.setCharacterEncoding("UTF-8") "

Usually, during run-time (within web-server container) this jar will be already in classpath. But during development inside IDE, you may face this compile time error.

You will find this JAR at path depending upon your installation path:For example,

C:\MyEclipse6.0\myeclipse\eclipse\plugins\com.genuitec.eclipse.j2eedt.core_6.0.0.zmyeclipse60020070820\data\libraryset\EE_5
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜