免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1478 | 回复: 1
打印 上一主题 下一主题

Struts中的中文乱码问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-01-03 20:55 |只看该作者 |倒序浏览
环境:netbeans5.5
页面代码:
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@ page import="com.myapp.struts.form.*"%>
<%@ page import="com.myapp.struts.work.*" %>
<%--
The taglib directive below imports the JSTL library. If you uncomment it,
you must also add the JSTL library to the project. The Add Library... action
on Libraries node in Projects view can be used to add the JSTL 1.1 library.
--%>
<%--
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
--%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<%
    TransDate td=new TransDate();
    ToLogaddForm tlf=(ToLogaddForm)session.getAttribute("data");
    int tmp=Integer.parseInt(tlf.getSeqno());
    tmp=tmp+1;
%>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>添加日志页面</title>
    </head>
    <body>

    <h1>添加日志</h1>
    <html:form action="logadd">
    <table>
        <tr>
            <td>流水号码</td><td><html:text property="seqno" value="<%=tmp+""%>" /></td>
        </tr>
        <tr>
            <td>用户编号</td><td><html:text property="userid" value="<%=tlf.getUserid()%>" /></td>
        </tr>
        <tr>
            <td>用户名称</td><td><html:text property="cnname" value="<%=tlf.getCnname()%>" /></td>
        </tr>
        <tr>
            <td>写入日期</td><td><html:text property="insdate" value="<%=td.getFullDate()%>" /></td>
        </tr>
        <tr>
            <td>写入内容</td><td><html:textarea property="content"/></td>
        </tr>
        <tr>
            <%
                System.out.println(request.getCharacterEncoding());
            %>
            <td><html:submit value="确定" /></td><td><html:cancel value="取消"/></td>
        </tr>
    </table>
    </html:form>
    <%--
    This example uses JSTL, uncomment the taglib directive above.
    To test, display the page like this: index.jsp?sayHello=true&name=Murphy
    --%>
    <%--
    <c:if test="${param.sayHello}">
        <!-- Let's welcome the user ${param.name} -->
        Hello ${param.name}!
    </c:if>
    --%>
   
    </body>
</html>
传到Action的时候content中的中文为乱码
不知为何,UTF-8??

论坛徽章:
0
2 [报告]
发表于 2007-01-04 12:30 |只看该作者

我已经解决了。呵呵

form 的地方
<html:form action="logadd" >
要加传值的get方法,否则默认的是POST
<html:form action="logadd" method="get">
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP