如何从__CODE__模型中读取模型变量并将其设置为Javascript?
请注意,我正在使用__CODE__模板引擎.
春方:
@RequestMapping(value = "message", method = RequestMethod.GET)
public String messages(Model model) {
model.addAttribute("message", "hello");
return "index";
}
Run Code Online (Sandbox Code Playgroud)
客户端:
<script>
....
var m = ${message}; // not working
alert(m);
...
</script>
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用mysql配置log4j v2,但它返回此错误:
2014-08-01 15:35:24,819 ERROR Unable to write to database [jdbcManager{ description=databaseAppender, bufferSize=0, connectionSource=factory{ public static java.sql.Connection it.prisma.presentationlayer.webui.ConnectionFactory.getDatabaseConnection() }, tableName=logs, columns=[ { name=message, layout=%message, literal=null, timestamp=false } ] }] for appender [databaseAppender]. org.apache.logging.log4j.core.appender.AppenderLoggingException: Cannot write logging event or flush buffer; JDBC manager cannot connect to the database.
Caused by: java.sql.SQLException: Failed to obtain connection from factory method.
Caused by: java.sql.SQLException: No suitable driver found for jdbc:mysql://10.41.1.68:3306/test
Run Code Online (Sandbox Code Playgroud)
我的配置类似于doc,唯一的区别是:
new PoolableConnectionFactory(connectionFactory, pool, null, "SELECT 1", false, false, Connection.TRANSACTION_READ_COMMITTED);
Run Code Online (Sandbox Code Playgroud)
我认为我的tomcat7配置得很好,因为我可以用log4j v1登录.