微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

将context.xml从Tomcat转换为Jetty

我在webapp / meta-inf /中有以下context.xml.
tomcat使用这个来定义 Spring将使用Property理解的值

<?xml version="1.0" encoding="UTF-8"?>
<Context>     
<Parameter name="si.host" value="super.com"  override="false"/>   
</Context>

现在我试图使用maven jetty插件部署webapp:

<plugin>
    <groupId>org.mortbay.jetty</groupId>
    <artifactId>maven-jetty-plugin</artifactId>
    <version>6.1.26</version>
    <configuration>
      <connectors>
        <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
          <port>8080</port>
          <maxIdleTime>60000</maxIdleTime>
        </connector>
      </connectors>
      <jettyEnvXml>${basedir}\src\test\resources\server\jetty\jetty-env.xml</jettyEnvXml>
      <jettyConfig>${basedir}\src\test\resources\server\jetty\jetty.xml</jettyConfig > 
       <contextpath>/myapp</contextpath>
      <webApp>target/myapp.war</webApp>
      <stopKey>foo</stopKey>
      <stopPort>9999</stopPort>
    </configuration>
    <executions>
      <execution>
        <id>start-jetty</id>
        <phase>pre-integration-test</phase>
        <goals>
          <goal>run</goal>
        </goals>
        <configuration>
          <scanIntervalSeconds>0</scanIntervalSeconds>
          <daemon>true</daemon>
        </configuration>
      </execution>
      <execution>
        <id>stop-jetty</id>
        <phase>post-integration-test</phase>
        <goals>
          <goal>stop</goal>
        </goals>
      </execution>
    </executions>        
  </plugin>

如何在jetty.xml文件添加此参数?
我已经深入研究了他们的文档,这里和谷歌,但没有发现任何明确的.
在此先感谢您的帮助.

解决方法

这需要进入你的WEB-INF / web.xml,这是独立于web服务器的,即它可以在tomcat和jetty中工作:

<context-param>
  <param-name>si.host</param-name>
  <param-value>super.com</param-value>
</context-param>

或者你可以在你的jetty xml中设置它像这样:

<Configure class="org.mortbay.jetty.webapp.WebAppContext">
  ...
  <Set name="initParams">
    <Map>
      <Entry>
        <Item>si.host</Item>
        <Item>super.com</Item>
      </Entry>
    </Map>
  </Set>
</Configure>

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。