- Jfinal 使用ajax 与后台交互
<!DOCTYPE html>
<html lang="en">
<head>
<script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<input type="text" id="fname" value="222" />
<button onclick="subAction()">测试</button>
<script type="application/javascript">
function subAction() {
$.ajax({
type: "POST",
dataType : "json",
url: "registe",
data: {
fname:$('#fname').val(),
lname:"22",
email:"222",
password:"2222",
},
success: function(res){
alert(res.msg);
}
});
}
</script>
这是主页
</body>
</html>
public void registe() {
String fname = getPara("fname");
setAttr("result", "1");
setAttr("msg", fname);
renderJson();
}
- 加载全局路径 cxt
handlers.add(new ContextPathHandler("cxt"));
- log4内置日志
log4j.properties
# log4j.rootLogger=WARN, stdout, file
log4j.rootLogger=ERROR, stdout, file
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%n%-d{yyyy-MM-dd HH:mm:ss}%n[%p]-[Thread: %t]-[%C.%M()]: %m%n
# Output to the File
log4j.appender.file=org.apache.log4j.DailyRollingFileAppender
log4j.appender.file.DatePattern='_'yyyy-MM-dd'.log'
log4j.appender.file.File=./jfinal_demo.log
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%n%-d{yyyy-MM-dd HH:mm:ss}%n[%p]-[Thread: %t]-[%C.%M()]: %m%n