如何通过XPath提取属性节点的值?
示例XML文件是:
<parents name='Parents'>
<Parent id='1' name='Parent_1'>
<Children name='Children'>
<child name='Child_2' id='2'>child2_Parent_1</child>
<child name='Child_4' id='4'>child4_Parent_1</child>
<child name='Child_1' id='3'>child1_Parent_1</child>
<child name='Child_3' id='1'>child3_Parent_1</child>
</Children>
</Parent>
<Parent id='2' name='Parent_2'>
<Children name='Children'>
<child name='Child_1' id='8'>child1_parent2</child>
<child name='Child_2' id='7'>child2_parent2</child>
<child name='Child_4' id='6'>child4_parent2</child>
<child name='Child_3' id='5'>child3_parent2</child>
</Children>
</Parent>
</parents>
Run Code Online (Sandbox Code Playgroud)
到目前为止,我有这个XPath字符串:
//Parent[@id='1']/Children/child[@name]
Run Code Online (Sandbox Code Playgroud)
它只返回child
元素,但我想拥有name
属性的值.
对于我的示例XML文件,这是我想要的输出:
Child_2
Child_4
Child_1
Child_3
Run Code Online (Sandbox Code Playgroud) 我在数据库和应用程序中有时间戳我确实有日期.我喜欢以hibernate可以将所有条目与日期匹配的方式编写hibernate标准,而不是时间部分.例如
在DB时间戳中
2011-12-01 15:14:14
在应用程序中,我确实有java.util.Date,它默认具有时间部分.
我的问题是,当我从数据库中搜索条目与以下代码我什么都没得到
DetachedCriteria criteria = DetachedCriteria.forClass(MyClass.class);
criteria.add(Restrictions.like(TIMESTAMP_FIELD, javaUtilDate));
List entries =this.getHibernateTemplate().findByCriteria(criteria);
Run Code Online (Sandbox Code Playgroud)
提前致谢
我正在尝试使用Grails中的Criteria加载不同的父级.查询如下
查询:
def criteria = Parent.createCriteria();
results = criteria.list(max:params.max, offset:params.offset){
projections{ groupProperty('id') }
children{
books{
like('title',"%book")
}
}
order("id","asc")
}
Run Code Online (Sandbox Code Playgroud)
域类
class Parent {
String name
static hasMany = [children:Child]
static constraints = {
}
}
class Child {
String name
Parent parent
static belongsTo = [parent:Parent]
static hasMany = [books:Book]
static constraints = {
}
}
class Book {
String title
Child child
static belongsTo = [child:Child]
static constraints = {
}
}
Run Code Online (Sandbox Code Playgroud)
问题:我无法获得明显的父行.
其他采用的方法及其结果:我不知道为什么groupProperty不工作.我尝试过 …
我正在寻找建立图像文件maven web项目的建议.src/main/java下的一个类需要使用图像文件.我的问题是,如果我将图像文件放在src/main/webapp/images以及src/main/resources/Images下,那么应用程序服务器在运行时(myeclipse可以在哪里)找不到该路径,因为war存档没有指定的路径"SRC /主/ web应用/图像".
我的问题是我应该在哪里放置我的项目可以找到它的图像文件,而不会提示任何错误或异常.
我在用
目前我确实有以下dir结构
项目目录结构
-src/main/java
-- classes
-src/main/resources
-- applicationContext.xml
-src/main/resources/Images
-- myImage.png (target image)
-src/test/java
-- test classes
-src/test/resources
(nothing)
-src
-- main
--- webapp
--WEB-INF
---faces-config.xml
---web.xml
--Images
--OtherImages
--myImage.png( second place for image)
--Css
--Meta-INF
--login.jspx
--jsfPageType1
--page1.jspx
--jsfPageType2
--page2.jspx
-target
-pom.xml
Run Code Online (Sandbox Code Playgroud)
而pom.xml的构建片段如下
<build>
<sourceDirectory>${basedir}/src/main/java</sourceDirectory>
<outputDirectory>${basedir}/target/${project.artifactId}/classes</outputDirectory>
<resources>
<resource>
<directory>${basedir}/src/main/resources</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
<testResources>
<testResource>
<directory>${basedir}/src/test/resources</directory>
</testResource>
</testResources>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration> …
Run Code Online (Sandbox Code Playgroud) 我想问一下启动jboss AS的最佳方法是什么.
因为,每当我关闭终端或按ctrl + c然后jboss(已经开始使用run.sh
脚本)时,请先关闭.我已经尝试过export LAUNCH_JBOSS_IN_BACKGROUND=1
在通过脚本启动jboss之前执行.run.sh
但是它对我帮助不大.
其次,我想知道如何验证jboss正在运行,除了浏览localhost:8080
或localhost:8080/admin-console
.
我正在使用mac-osx/linux和Jboss-AS-6.0.0.Final.
我想知道如何在EL中组合多个布尔条件.我有以下示例,它不起作用.
<x:someComponent rendered="#{bean.condition1} or #{bean.condition2}">
Run Code Online (Sandbox Code Playgroud)
如何在EL中使用"OR"和"AND"逻辑运算符?
hibernate ×2
java ×2
and-operator ×1
el ×1
grails ×1
grails-orm ×1
itext ×1
jboss6.x ×1
jsf ×1
maven ×1
maven-2 ×1
or-operator ×1
xml ×1
xpath ×1