小编Rit*_*esh的帖子

从请求中获取根域

以下面的URL为例. http://www.test1.example.com

有什么方法可以让"example.com"作为输出.我知道有一种方法servletrequest.getServerName().它给我输出test1.example.com

任何帮助赞赏.

java servlets

35
推荐指数
2
解决办法
5万
查看次数

输出空元素

我有一个带有两个字段"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)

请帮助我获得所需的输出.

提前致谢.

jaxb

6
推荐指数
1
解决办法
2万
查看次数

XSLT查找是否存在兄弟姐妹

示例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是否存在.请帮我.

提前致谢.

xslt xpath

4
推荐指数
1
解决办法
1万
查看次数

Jax-rs apache-cxf:没有找到资源类的资源方法

我有以下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)

java rest spring web-services cxf

4
推荐指数
1
解决办法
3638
查看次数

在Spring OSGI中使用pax-runner登录

我们正在使用pax-runner 运行OSGI捆绑软件。我们正在通过slf4j使用logback进行日志记录。

问题是logback试图在类路径中查找logback.xml,但是在pax-runner中应该将logback.xml放在哪里,以便pax-runner相应地配置logback?

我曾尝试使用JoranConfigurator加载包类路径中包含的logback.xml,但它假定类路径为包在其中运行的容器(在我的情况下,它是放置所有包罐的Runner文件夹)。

任何帮助,将不胜感激。

非常感谢。

osgi logback pax-runner

2
推荐指数
1
解决办法
780
查看次数

标签 统计

java ×2

cxf ×1

jaxb ×1

logback ×1

osgi ×1

pax-runner ×1

rest ×1

servlets ×1

spring ×1

web-services ×1

xpath ×1

xslt ×1