简体   繁体   中英

Encoding in forms doesn't work

I'm passing some information from a JSP to another one. This is the way I call the second JSP page:

<form action="second.jsp" method="POST">
    <button type="submit">Click</button>
    <input type="hidden" name="title" value="El balcón de Andalucía">
</form>

And here is the second.jsp page (simplified):

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">    
        <title>${param['title']}</title>
    </head>
    <body>
    </body>
</html>

The problem is that the title should be " El balcón de Andalucía ", but it appears with encoding errors as " El balcón de AndalucÃa ", and both pages are specifying that are using utf-8 content.

Where's the problem?

Thanks!

And in the end, I could resolve it.

I just add this line to the file second.jsp, at the top:

<% request.setCharacterEncoding("UTF-8"); %>

That's all.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM