NutzCN Logo
问答 用nutzWk开发的微信公众号,服务器是linux,写入数据乱码
发布于 2209天前 作者 qq_6428ccea 1868 次浏览 复制 上一个帖子 下一个帖子
标签: nutzwk

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title></title>
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <link href="${base}/assets/attorney/css/mui.min.css" rel="stylesheet" />
    <link rel="stylesheet" type="text/css" href="${base}/assets/attorney/css/wyhs.css" />
    <link rel="stylesheet" type="text/css" href="${base}/assets/attorney/css/weuix.min.css" />

    <script type="text/javascript" src="${base}/assets/attorney/js/mui.min.js" ></script>
    <script src="${base}/assets/attorney/js/jquery-3.3.1.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="${base}/assets/attorney/js/app.js"></script>

</head>

<body >
    <div id="content" class="mui-content-bg" >

         <form action="${base}/messageAdd" method="post" class="mui-input-groups" >
          <span class="mui-input-tipcontent">您可以反映侵害未成年人合法权益的相关问题,我们会及时处理,并通过预留电话或者邮箱回复您的问题。</span>
          <div class="mui-input-row">
                 <label>您的称呼</label>
                 <input type="text" name="userName" id="userName" value="" placeholder="请输入您的称呼" />
              </div>
              <div class="mui-input-row">
                 <label>您的电话</label>
                 <input type="tel" name="linkPhone" id="linkPhone" value="" placeholder="请输入手机号或固定电话"/>
              </div>
              <div class="mui-input-row">
                 <label>您的邮箱</label>
                 <input type="email" name="email" id="email" value=""  placeholder="请输入您的邮箱"/>
              </div>
              <div class="mui-input-row" style="height:120px;">
                 <label>反映内容</label>
                 <textarea name="preachContent" id="preachContent" cols="30" rows="4" value=""  placeholder="请输入您的反映内容"></textarea>
              </div>

提  交

这个是Controller
@At({"/messageAdd"})
@POST
@Ok("beetl:/platform/qt_attorney/message_tip.html")
@SLog(
tag = "我有话说",
msg = "${args[0].id}"
)
public void messageAdd(@Param("..") Attorney_Message attorneyMessage, HttpServletRequest req) {
try {
Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
attorneyMessage.setCreateTime(sdf.format(date));
attorneyMessage.setStatus("01");
Wx_config config = (Wx_config)this.wxConfigService.fetch(Cnd.NEW().limit(1, 1));
String wxid = config.getId();
WxApi2 wxApi2 = this.wxConfigService.getWxApi2(wxid);
if (Lang.isEmpty(Globals.memoryJsapiTicketStore.get(wxid))) {
Globals.memoryJsapiTicketStore.put(wxid, new MemoryJsapiTicketStore());
}

        MemoryJsapiTicketStore memoryJsapiTicketStore = (MemoryJsapiTicketStore)Globals.memoryJsapiTicketStore.get(wxid);
        wxApi2.setJsapiTicketStore(memoryJsapiTicketStore);
        String picPath = ";";
        String picPaths = req.getParameter("picPath");
        if (!StringUtils.isEmpty(picPaths)) {
            String[] pics = picPaths.split(",");

            for(int i = 1; i < pics.length; ++i) {
                String var10000 = pics[i];
                NutResource nutResource = wxApi2.media_get(pics[i]);
                String p = Globals.AppRoot;
                String f = Globals.AppUploadPath + "/image/" + DateUtil.format(new Date(), "yyyyMMdd") + "/" + R.UU32();
                Files.write(new File(p + f + ".jpg"), nutResource.getInputStream());
                picPath = picPath + Globals.AppBase + f + ".jpg;";
            }
        }

        attorneyMessage.setPicPath(picPath);
        if (!attorneyMessage.getUserName().isEmpty() && !attorneyMessage.getPreachContent().isEmpty()) {
            this.attorneyMessageService.insert(attorneyMessage);
        }

        Result.success("system.success");
    } catch (Exception var17) {
        Result.error("system.error");
    }

}

用nutzWk开发的微信公众号,服务器是linux,数据库是mysql(编码已经改成utf-8)
首次发布的都为乱码 之后就正常显示了

4 回复

https://nutzam.com/core/mvc/whale_filter.html
加上这个过滤器

<filter>
    <filter-class>org.nutz.mvc.WhaleFilter</filter-class>
    <filter-name>whale</filter-name>
    <init-param>
        <param-name>config</param-name>
        <param-value>
        enc.input=utf-8
        enc.output=utf-8
        </param-value>
    </init-param>
</filter>
<filter-mapping>
    <filter-name>whale</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

tomcat 已设置bin\setenv.bat
mysql也修改了
就重启服务前一两次提交乱码之后就好了

那应该是shiro的问题, 加WhaleFilter吧

添加回复
请先登陆
回到顶部