【问题标题】:Non-English characters are all broken in JSP fileJSP 文件中的非英文字符全部损坏
【发布时间】:2017-12-15 10:33:53
【问题描述】:

我正在修改一个 JSP 文件,其中的所有日文字符都没有显示如下。

<input type="submit" name="form" value="ç»é²"> <!-- MEMO æãã¯ãããã£ã¦ãããã<button name="form">ç»é²</button> 
<input type=button ãããªã®ã¯å­å¨ããªã-->

能恢复吗?


*我添加了更多信息:

  1. 编辑:STS

  2. 编码:UTF-8

  3. 日文的编码已经是UTF-8,所以我什么都没做。

  4. 更多示例:

header.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>

loginForm.jsp

<%@include file="/WEB-INF/views/common/header.jsp"%>
<div align="center">
<form action="${pageContext.request.contextPath}/top" method="GET"> <!-- FIXME postã«修正 -->
    <table border="0">
        <tr>
            <td>ã¦ã¼ã¶ID:</td>
            <td><input type="text" name="userId" /></td>
        </tr>

        <tr>
            <td>ãã¹ã¯ã¼ã:</td>
            <td><input type="password" name="password" /></td>
        </tr>       
    </table>

<input type="submit" value="ã­ã°ã¤ã³"/>

【问题讨论】:

  • 你用的是什么编辑器? JSP 文件的编码是什么(例如 UTF-8)?你试过在编辑器中切换编码吗?
  • @JozefChocholacek 我添加了更多信息。
  • @JozefChocholacek 我自己解决了。如果我尝试切换编码,我从您的建议中得到了提示。谢谢!

标签: jsp


【解决方案1】:

解决方案:

这是 JSP 编码问题。 Java文件没有问题。 所以解决办法是……

STS 菜单 -> 首选项 -> 常规 -> 内容类型 -> 文本 -> JSP -> 默认编码 -> 写 UTF-8 -> OK

然后我们可以看到破碎的字符已经变成了原来的样子。


*参考文献(日文):

http://proengineer.internous.co.jp/content/columnfeature/9147#section001 http://d.hatena.ne.jp/gnarl/20090317/1237290886

【讨论】:

    猜你喜欢
    • 2021-07-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-04-02
    • 2016-11-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多