我正在阅读有关使用Mustache.js进行模板化的内容.我不明白的是如何放置模板.我不会把它们放在同一个文件中.
$.get('test.htm', function(templates) {
// Fetch the <script /> block from the loaded external
// template file which contains our greetings template.
var template = $(templates).filter('#tpl-greeting').html();
$('body').append(Mustache.render(template, templateData));
});
//test.htm
<script id="tpl-greeting" type="text/html">
<dl>
<dt>Name</dt>
<dd>{{name}}</dd>
<dt>Time</dt>
<dd>{{timeNow}}</dd>
</dl>
</script>
Run Code Online (Sandbox Code Playgroud)
我是否必须创建一个返回我的模板的控制器或者我可以参考它?
是否可以验证字符是M还是F还是我需要使用带正则表达式的字符串?
@Pattern(regexp = "^[MF]{1}$", message = "customer.sex.regex")
private String sex;
Run Code Online (Sandbox Code Playgroud)
我想用
private Character sex;
Run Code Online (Sandbox Code Playgroud) 嗨,我正在尝试做与文档中相同的事情
http://docs.jboss.org/hibernate/orm/4.1/manual/en-US/html/ch07.html#d5e5275
为什么会这样?
//In class Team
@ManyToOne
@JoinColumn(name = "Heat")
public Heat getHeat() {
return heat;
}
//In class Heat
@OneToMany(fetch = FetchType.LAZY, mappedBy = "heat")
@OrderColumn(name = "Heat_index")
public List<Team> getTeams() {
return teams;
}
Run Code Online (Sandbox Code Playgroud)
Heat_index列已创建但我得到此异常.
org.hibernate.HibernateException: null index column for collection: no.domain.Heat.teams
at org.hibernate.persister.collection.AbstractCollectionPersister.readIndex(AbstractCollectionPersister.java:766) ~[hibernate-core-4.1.1.Final.jar:4.1.1.Final]
at org.hibernate.collection.internal.PersistentList.readFrom(PersistentList.java:402) ~[hibernate-core-4.1.1.Final.jar:4.1.1.Final]
at org.hibernate.loader.Loader.readCollectionElement(Loader.java:1185) ~[hibernate-core-4.1.1.Final.jar:4.1.1.Final]
at org.hibernate.loader.Loader.readCollectionElements(Loader.java:800) ~[hibernate-core-4.1.1.Final.jar:4.1.1.Final]
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:651) ~[hibernate-core-4.1.1.Final.jar:4.1.1.Final]
at org.hibernate.loader.Loader.doQuery(Loader.java:850) ~[hibernate-core-4.1.1.Final.jar:4.1.1.Final]
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:289) ~[hibernate-core-4.1.1.Final.jar:4.1.1.Final]
at org.hibernate.loader.Loader.doList(Loader.java:2447) ~[hibernate-core-4.1.1.Final.jar:4.1.1.Final]
at org.hibernate.loader.Loader.doList(Loader.java:2433) ~[hibernate-core-4.1.1.Final.jar:4.1.1.Final]
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2263) ~[hibernate-core-4.1.1.Final.jar:4.1.1.Final]
at org.hibernate.loader.Loader.list(Loader.java:2258) ~[hibernate-core-4.1.1.Final.jar:4.1.1.Final]
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:470) ~[hibernate-core-4.1.1.Final.jar:4.1.1.Final] …Run Code Online (Sandbox Code Playgroud) 我一直在谷歌搜索,但不明白调用方法关联javax.persistence.criteria.Subquery与Criteria API的结果.
http://www.objectdb.com/api/java/jpa/criteria/Subquery/correlate_CollectionJoin_
这是来自Pro JPA2掌握Java Persistence API的书.
在为此查询创建条件API查询定义时,我们必须关联Project的employees属性,然后将其加入直接报告以计算平均工资.此示例还演示了如何使用Path接口的type()方法来进行类型的多态比较:
CriteriaQuery<Project> c = cb.createQuery(Project.class);
Root<Project> project = c.from(Project.class);
Join<Project,Employee> emp = project.join("employees");
Subquery<Number> sq = c.subquery(Number.class);
Join<Project,Employee> sqEmp = sq.correlate(emp);
Join<Employee,Employee> directs = sqEmp.join("directs");
c.select(project)
.where(cb.equal(project.type(), DesignProject.class),
cb.isNotEmpty(emp.<Collection>get("directs")),
cb.ge(sq, cb.parameter(Number.class, "value")));
Run Code Online (Sandbox Code Playgroud)
这条线做什么?
加入sqEmp = sq.correlate(emp);
这位明星做了什么?这叫什么?对我来说这是一种外卡.它叫什么,所以我可以读到它?
#div {
*zoom: 1; /*this ... *
zoom : 1;
display: inline;
*display: inline; /*... and this, whats the difference? *
}
Run Code Online (Sandbox Code Playgroud)
我知道这意味着什么(所有元素):
* {
..css code
}
Run Code Online (Sandbox Code Playgroud) 有什么方法可以使我的字体比下面的示例更粗吗?我尝试font-weight过从 900 增加到 1500,但我没有看到任何差异。
#step-1 div {
font-weight: bolder;
font-weight: 900;
}
Run Code Online (Sandbox Code Playgroud) xslt对我来说很新鲜.是否可以执行类似于下面的代码.我知道其他模板语言是可行的.
<div class="<xsl:if test="position()=1">myclass</xsl:if>">Hello</div>
Run Code Online (Sandbox Code Playgroud) 如何获取freemarker模板中使用的当前区域设置?我见过实施<spring.message code />
我需要这个做有条件的
<#if locale = DE >
.....
<#else>
....
</#if>
Run Code Online (Sandbox Code Playgroud) 有没有办法使用@ResponseBody注释将空值映射到空字符串?
我已经验证了这个HTML.当我在IE浏览器中打开它时,我看不到任何警报.在其他浏览器中,我可以.任何想法为什么会这样.根据http://validator.w3.org/check,HTML有效.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/1998/REC-html40-19980424/loose.dtd">
<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>hello</title>
</head>
<body>
<script type="text/javascript">alert("hallo");</script>
<div>Hello</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud) css ×2
hibernate ×2
javascript ×2
jpa-2.0 ×2
spring ×2
spring-mvc ×2
criteria ×1
criteria-api ×1
css3 ×1
freemarker ×1
jackson ×1
jpa ×1
jquery ×1
mustache ×1
xslt ×1