以下面的URL为例. http://www.test1.example.com
有什么方法可以让"example.com"作为输出.我知道有一种方法servletrequest.getServerName().它给我输出test1.example.com
任何帮助赞赏.
我有一个带有两个字段"name"和"address"的Object.JAXB在将对象转换为XMl时忽略空元素.
例如:如果我有name ="xyz"并且address = null那么out将是
<name>xyz</name>
Run Code Online (Sandbox Code Playgroud)
但我想要的输出是什么
<name>xyz</name>
<address></address>
Run Code Online (Sandbox Code Playgroud)
我看过这个选项,@XmlElement(nillable="true")但这会给出输出
<name>xyz</name>
<address xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
Run Code Online (Sandbox Code Playgroud)
请帮助我获得所需的输出.
提前致谢.
示例XML如下.
<mapNode>
<mapNode>...</mapNode>
<mapNode>...</mapNode>-----I am here at 2
<mapNode>...</mapNode>
<mapNode>...</mapNode>
</mapNode>
<mapNode>
<mapNode>...</mapNode>
<mapNode>...</mapNode>
</mapNode>
Run Code Online (Sandbox Code Playgroud)
我想知道位置3是否存在.请帮我.
提前致谢.
我有以下cxf配置文件
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xmlns:jaxrs="http://cxf.apache.org/jaxrs"
xmlns:jpa="http://www.springframework.org/schema/data/jpa"
xmlns:cxf="http://cxf.apache.org/core"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd">
<import resource="classpath:META-INF/cxf/cxf.xml"/>
<import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>
<context:component-scan base-package="test.stub.rest" />
<!-- Enable CXF logging -->
<cxf:bus>
<cxf:features>
<cxf:logging/>
</cxf:features>
</cxf:bus>
<!-- CXF Services -->
<jaxrs:server id="test" address="/stub/postUrl">
<jaxrs:serviceBeans>
<ref bean="testClass" />
</jaxrs:serviceBeans>
</jaxrs:server>
<bean id="testClass" class="test.stub.rest.TestClass">
</bean>
</beans>
Run Code Online (Sandbox Code Playgroud)
web.xml中
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<display-name>Stubby CXF</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:spring/stub-cxf-applicationContext.xml
</param-value>
</context-param> …Run Code Online (Sandbox Code Playgroud) 我们正在使用pax-runner 运行OSGI捆绑软件。我们正在通过slf4j使用logback进行日志记录。
问题是logback试图在类路径中查找logback.xml,但是在pax-runner中应该将logback.xml放在哪里,以便pax-runner相应地配置logback?
我曾尝试使用JoranConfigurator加载包类路径中包含的logback.xml,但它假定类路径为包在其中运行的容器(在我的情况下,它是放置所有包罐的Runner文件夹)。
任何帮助,将不胜感激。
非常感谢。