如何在JSP页面上提交和显示Unicode数据(非英语) [英] How to submit and display Unicode data(non English) on JSP page

查看:98
本文介绍了如何在JSP页面上提交和显示Unicode数据(非英语)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当天的问候. 我有一个jsp页面,其中包含两个单独的表单标签中的两个文本区域.我想在一个文本区域中提交unicode日期,并在另一个文本区域中显示它.但是没有任何东西对我有用.我必须基本上显示所有印度语言和英语.请帮助我.这是它的代码:

Greetings for the day. i have a jsp page which contains two text areas inside two separate form tags. i want to submit unicode date in one textarea and display it in another. But nothing is working for me. i have to show basically all Indian Languages and english as well. kindly help me. here is the code of it :

<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ page pageEncoding="UTF-8" %>
<%@ page language="java" %>

<!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>

<script type="text/javascript">
    alert("गुजरात के प्राइमरी और हाई स्कूलों में अब वही ");
</script>
</head>
<body>
<div>
<%@ include file="navigator.jsp" %>
<s:form action="content.action" method="post" >


<%request.setCharacterEncoding("UTF-8"); %>
 <s:textarea name="contentBean.data"  rows="10" cols="100"  />
<s:submit id="submitButton" method="execute" onclick="pressed();" />

        </s:form>

</div> 
   <div>
        <form action="formAction.jsp" method="GET">
            Please enter your text:
            <BR>
            <TEXTAREA NAME="textarea1" ROWS="10" cols="100"><s:property value="contentBean.data" /></TEXTAREA>
            <BR>
            <INPUT TYPE="SUBMIT" VALUE="Submit">

        </form>
        </div>
</body>
</html>

推荐答案

步骤1:删除第一行

<%@ page contentType="text/html; charset=UTF-8"%> // remove this line

然后将以下行放在您的head标签中

and put following line in your head tag

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    ...
</head>

第2步::确保jsp页面的编码为UTF-8,右键单击jsp页面,属性,然后选择UTF-8作为编码.

Step 2 : Make sure your jsp page's encoding is UTF-8, right click jsp page, properties and select UTF-8 as encoding.

步骤3: [如果您不使用数据库,则是可选的]如果您正在使用数据库,请确保数据库的排序规则为utf-8,否则数据库将不会存储您的非英语数据.

Step 3: [Optional if you are not using database] If you are using database, make sure the database's collation is utf-8, otherwise database will not store your non English data.

这篇关于如何在JSP页面上提交和显示Unicode数据(非英语)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆