jsp传到action信息乱码,检查过页面、eclipse、tomcat 均配置了utf-8不知道还有什么不正确的地方了
2016-12-08 20:30:02,419 org.nutz.mvc.impl.NutLoading.load(NutLoading.java:61) DEBUG - - Default Charset : UTF-8
<%@ 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">
项目信息列表
---------------------------------------------------------------
---------------------------------------------------------------
<%--
--%>
<div id="div1" class="div1 Absolute-Center">This is another DIV</div>
编辑接口项目信息
名称:*
</li>
<li class="clearfix">
<label style="width:100px;">描述:</label>
<div style="width:60%;"><textarea name="description" id="description" ></textarea></div>
</li>
</ul>
</form>
</div>
<div class="buttons">
<button onclick='editcommit()'>确定</button>
<button onclick='editcancel()'>取消</button>
</div>
</div>
<%@ 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>项目信息列表</title>
<script type="text/javascript" src="http://lib.sinaapp.com/js/jquery/2.0.3/jquery-2.0.3.min.js"></script>
<style type="text/css">
table.gridtable {
font-family: verdana,arial,sans-serif;
font-size:11px;
color:#333333;
border-width: 1px;
border-color: #666666;
border-collapse: collapse;
}
table.gridtable th {
border-width: 1px;
padding: 8px;
border-style: solid;
border-color: #666666;
background-color: #dedede;
}
table.gridtable td {
border-width: 1px;
padding: 8px;
border-style: solid;
border-color: #666666;
background-color: #ffffff;
}
.Absolute-Center {
margin: auto;
position: absolute;
top: 0; left: 0; bottom: 0; right: 0;
}
.div1{
position:absolute;
display:none;
width: 300px;
height: 300px;
background-color: yellow;
}
</style>
<script type="text/javascript">
var pageNumber = 1;
var pageSize = 10;
var base = '<%=request.getAttribute("base")%>';
function intertype_reload() {
$.ajax({
url : base + "/interfacetype/query",
data : $("#intertype_query_form").serialize(),
dataType : "json",
success : function(data) {
console.log(data);
$("#intertype_count").html("共"+data.pager.recordCount+"个接口, 总计"+data.pager.pageCount+"页");
var list_html = "";
console.log(data.list);
for (var i=0;i<data.list.length;i++) {
var intertype = data.list[i];
console.log(intertype);
var tmp = "\n<p>" + intertype.id + "---- " + intertype.name+ "--- " + intertype.description
+ " <button onclick='intertype_update(" + intertype.id +");'>修改</button> "
+ " <button onclick='intertype_delete(" + intertype.id +");'>删除</button> "
+ "</p>";
list_html += tmp;
}
$("#intertype_list").html(list_html);
}
});
}
$(function() {
intertype_reload();
$("#intertype_query_btn").click(function() {
intertype_reload();
});
$("#intertype_add_btn").click(function() {
$.ajax({
url : base + "/interfacetype/add",
data : $("#intertype_add_form").serialize(),
dataType : "json",
success : function(data) {
if (data.ok) {
intertype_reload();
alert("添加成功");
} else {
alert(data.msg);
}
}
});
});
});
//运行
function intertype_run(intertypeId) {
var passwd = prompt("请输入新的密码");
if (passwd) {
$.ajax({
url : base + "/interfacetype/update",
data : {"id":intertypeId,"password":passwd},
dataType : "json",
success : function (data) {
if (data.ok) {
intertype_reload();
alert("修改成功");
} else {
alert(data.msg);
}
}
});
}
};
//修改
function intertype_update(intertypeId) {
var passwd = prompt("请输入新的密码");
if (passwd) {
$.ajax({
url : base + "/interfacetype/update",
data : {"id":intertypeId,"password":passwd},
dataType : "json",
success : function (data) {
if (data.ok) {
intertype_reload();
alert("修改成功");
} else {
alert(data.msg);
}
}
});
}
};
//删除
function intertype_delete(intertypeId) {
var s = prompt("请输入y确认删除");
if (s == "y") {
$.ajax({
url : base + "/interfacetype/delete",
data : {"id":intertypeId},
dataType : "json",
success : function (data) {
if (data.ok) {
intertype_reload();
alert("删除成功");
} else {
alert(data.msg);
}
}
});
}
};
function addIntertype()
{
var name = prompt("请输入您的名字", ""); //将输入的内容赋给变量 name ,
//这里需要注意的是,prompt有两个参数,前面是提示的话,后面是当对话框出来后,在对话框里的默认值
if (name)//如果返回的有内容
{
alert("欢迎您:" + name)
}
//alert("页面正在修改,请稍后重试!");
};
function div1Show() {
var div1 = document.getElementById("edit-dialog");
div1.style.display = "block";
};
</script>
</head>
<body>
<div>
<form action="#" id="intertype_query_form">
条件<input type="text" name="name">
页数<input type="text" name="pageNumber" value="1">
每页<input type="text" name="pageSize" value="10">
</form>
<button id="intertype_query_btn">查询</button>
<p>---------------------------------------------------------------</p>
<p id="intertype_count"></p>
<div id="intertype_list">
</div>
</div>
<div>
<p>---------------------------------------------------------------</p>
</div>
<div id="intertype_add">
<form action="#" id="intertype_add_form">
项目名称<input name="name">
项目描述<input name="description">
</form>
<button id="intertype_add_btn">新增</button>
</div>
<!-- <div>
<p>---------------------------------------------------------------</p>
</div>
<div id="intertype_table">
<table class="gridtable">
<tr>
<th>接口名称</th><th>URL</th><th>操作</th>
</tr>
<tr>
<td><input type="text" name="pageNumber" value="intertype.id"></td><td>intertype.name</td><td>intertype.id</td>
</tr>
<tr>
<td>Text 2A</td><td>Text 2B</td><td>Text 2C</td>
</tr>
</table>
</div> -->
<%-- <div class="toolbar clearfix">
<!-- 新增学生信息-->
<a href="javascript://" onclick="div1Show()" id="btn-add">
<img src="${base}/jspsupport/images/add.png" alt='新增学生信息' title='新增学生信息' />
</a>
</div> --%>
<div id="div1" class="div1 Absolute-Center">This is another DIV</div>
<!-- 新增/编辑学生信息-->
<div id="edit-dialog" class="div1 Absolute-Center" style="display:none;">
<h2>编辑接口项目信息</h2>
<div>
<form id="group-form" >
<ul id="addAndEditGroup">
<li class="clearfix">
<label style="width:100px;">名称:<em>*</em></label>
<div style="width:60%;"><input type="text" name="name" id="tree-name" /></div>
</li>
<li class="clearfix">
<label style="width:100px;">描述:</label>
<div style="width:60%;"><textarea name="description" id="description" ></textarea></div>
</li>
</ul>
</form>
</div>
<div class="buttons">
<button onclick='editcommit()'>确定</button>
<button onclick='editcancel()'>取消</button>
</div>
</div>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" trimDirectiveWhitespaces="true"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!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>用户详情页</title>
<script type="text/javascript"
src="http://cdn.staticfile.org/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
var base = '${base}';
$.fn.serializeObject = function() {
var o = {};
var a = this.serializeArray();
$.each(a, function() {
if (o[this.name] !== undefined) {
if (!o[this.name].push) {
o[this.name] = [ o[this.name] ];
}
o[this.name].push(this.value || '');
} else {
o[this.name] = this.value || '';
}
});
return o;
};
$(function() {
$("#user_profile_btn").click(function() {
//alert(JSON.stringify($("#user_profile").serializeObject()));
$.ajax({
url : base + "/user/profile/update",
type : "POST",
data : JSON.stringify($("#user_profile").serializeObject()),
success : function() {
location.reload();
}
});
});
});
</script>
</head>
<body>
<div>
<div>
头像 <img alt="用户头像" src="${base}/user/profile/avatar">
<p />
<form action="${base}/user/profile/avatar" method="post"
enctype="multipart/form-data">
头像文件 <input type="file" name="file">
<button type="submit">更新头像</button>
</form>
<span class="color:#f00"> <%
if (session.getAttribute("upload-error-msg") != null) {
String msg = session.getAttribute("upload-error-msg")
.toString();
out.print(msg);
session.removeAttribute("upload-error-msg");
}
%>
</span><p />
</div>
</div>
<div>
<form action="#" id="user_profile" method="post">
<div>
id:<c:out value="${obj.userId}"></c:out><p />
</div>
<div>
昵称:<input name="nickname" value="${obj.nickname}"><p />
</div>
<div>
邮箱:<input name="email" value="${obj.email}">
<p />
</div>
<div>
邮箱验证状态:<c:out value="${obj.emailChecked}"></c:out><p />
<c:if test="${!obj.emailChecked}">
<script type="text/javascript">
function send_email_check() {
$.ajax({
url : base + "/user/profile/active/mail",
type : "POST",
dataType : "json",
success : function (data) {
if (data.ok) {
alert("发送成功");
} else {
alert(data.msg);
}
}
});
}
</script>
<button type="button" onclick="send_email_check();return false;">发送验证邮件</button>
</c:if>
</div>
<div>
性别:<input name="gender" value="${obj.gender}"><p />
</div>
<div>
自我介绍:<input name="description" value="${obj.description}"><p />
</div>
<div>
地理位置:<input name="location" value="${obj.location}"><p />
</div>
</form>
<button type="button" id="user_profile_btn">更新</button>
</div>
</body>
</html>
我在页面编辑用户信息时,填写中文,传到module就是乱码的
这段?
$("#user_profile_btn").click(function() {
//alert(JSON.stringify($("#user_profile").serializeObject()));
$.ajax({
url : base + "/user/profile/update",
type : "POST",
data : JSON.stringify($("#user_profile").serializeObject()),
success : function() {
location.reload();
}
});
});
$.ajax 之前加一句
console.log($("#user_profile").serializeObject());
console.log(JSON.stringify($("#user_profile").serializeObject()));
debug了下,加上后,传过去的信息profile没有乱码,但执行下句后乱码,数据库中是乱的
Daos.ext(dao, FieldFilter.create(UserProfile.class, null, "avatar", true)).update(profile);
2016-12-08 21:06:41,875 org.nutz.dao.jdbc.Jdbcs.(Jdbcs.java:90) DEBUG - Jdbcs init complete
2016-12-08 21:06:41,875 org.nutz.dao.jdbc.Jdbcs.getExpert(Jdbcs.java:103) INFO - Get Connection from DataSource for JdbcExpert, if I lock at here, check your database server and configure
2016-12-08 21:06:42,537 org.nutz.dao.impl.DaoSupport$1.invoke(DaoSupport.java:200) DEBUG - JDBC Driver --> mysql-connector-java-5.1.40 ( Revision: 402933ef52cad9aa82624e80acbea46e3a701ce6 )
2016-12-08 21:06:42,537 org.nutz.dao.impl.DaoSupport$1.invoke(DaoSupport.java:201) DEBUG - JDBC Name --> MySQL Connector Java
2016-12-08 21:06:42,537 org.nutz.dao.impl.DaoSupport$1.invoke(DaoSupport.java:203) DEBUG - JDBC URL --> jdbc:mysql://127.0.0.1:3306/nutzbook
2016-12-08 21:06:42,549 org.nutz.dao.impl.DaoSupport$1.invoke(DaoSupport.java:219) DEBUG - Mysql : character_set_client=latin1
2016-12-08 21:06:42,549 org.nutz.dao.impl.DaoSupport$1.invoke(DaoSupport.java:219) DEBUG - Mysql : character_set_connection=latin1
2016-12-08 21:06:42,549 org.nutz.dao.impl.DaoSupport$1.invoke(DaoSupport.java:219) DEBUG - Mysql : character_set_database=utf8
2016-12-08 21:06:42,550 org.nutz.dao.impl.DaoSupport$1.invoke(DaoSupport.java:219) DEBUG - Mysql : character_set_filesystem=binary
2016-12-08 21:06:42,550 org.nutz.dao.impl.DaoSupport$1.invoke(DaoSupport.java:219) DEBUG - Mysql : character_set_results=
2016-12-08 21:06:42,550 org.nutz.dao.impl.DaoSupport$1.invoke(DaoSupport.java:219) DEBUG - Mysql : character_set_server=latin1
2016-12-08 21:06:42,550 org.nutz.dao.impl.DaoSupport$1.invoke(DaoSupport.java:219) DEBUG - Mysql : character_set_system=utf8
2016-12-08 21:06:42,551 org.nutz.dao.impl.DaoSupport$1.invoke(DaoSupport.java:219) DEBUG - Mysql : character_sets_dir=C:\Program Files\MySQL\mysql-5.6.10-winx64\share\charsets\
2016-12-08 21:06:42,552 org.nutz.dao.impl.DaoSupport$1.invoke(DaoSupport.java:226) DEBUG - Mysql : database=nutzbook
2016-12-08 21:06:42,553 org.nutz.dao.impl.DaoSupport$1.invoke(DaoSupport.java:232) DEBUG - Mysql : user=root@localhost
2016-12-08 21:06:42,590 org.nutz.dao.impl.DaoSupport.setDataSource(DaoSupport.java:247) DEBUG - Database info --> MYSQL:[MySQL - 5.6.10]
2016-12-08 21:06:42,609 org.nutz.resource.Scans.scan(Scans.java:262) DEBUG - Found 33 resource by src( net/gyb/accumulation/ ) , regex( ^.+[.]class$ )