开发者

HttpServletResponse issue.setCharacterEncoding: Depend attribute is not supported by modern compiler

In my java class I am trying to do something like

HttpServletResponse.setCharacterEncoding("UTF-8");

but the code fails to compile with the message:

Depend attribute is not supported by modern compiler.

If I remove this line, code compiles without any issues.

Can anyone shed any light on 开发者_开发百科this?

Thanks


HttpServletResponse.setCharacterEncoding() is not a static method. You need to call it on an instance. Something like: (assuming your instance is called resp)

resp.setCharacterEncoding("UTF-8");

Alternatively, you could set character encoding in the Content-type header like this:

resp.setContentType("text/html; charset=UTF-8")

EDIT: Ok, by your comments, I see you are already doing this. I took the wording of the question literally. Anyway, the problem is most likely that you are using javac with dependency tracking turned on. It's a flag you can pass on the command line (or an attribute to the <javac> ant task). Turn off dependency tracking. It's not supported by Sun's compiler.


Did you try to remove the -depend option when invoking javac (which is not supported by modern compiler :).

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜