在Jetty 8.1.12中将dirAllowed设置为false [英] Setting dirAllowed to false in Jetty 8.1.12

查看:779
本文介绍了在Jetty 8.1.12中将dirAllowed设置为false的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是Jetty 6.x,我们创建了一个基于Spring的Jetty服务器,并将dirAllowed设置为false。
配置如下。

I was using Jetty 6.x where we created a spring based Jetty server with dirAllowed set to false. The config is as follows.

<bean id="Server" class="org.mortbay.jetty.Server" init-method="start" destroy-method="stop">
    <property name="connectors">
        <list>
            <bean id="Connector" class="org.mortbay.jetty.nio.SelectChannelConnector">
                <property name="port" value="${tnplportal.jettyServer.httpPort}" />
                <property name="headerBufferSize" value="${tnplportal.jettyServer.headerBufferSize}" />
            </bean>
        </list>
    </property>

    <property name="handler">
        <bean id="handlers" class="org.mortbay.jetty.handler.HandlerCollection">
            <property name="handlers">
                <list>
                    <bean id="contexts" class="org.mortbay.jetty.handler.ContextHandlerCollection">
                        <property name="handlers">
                            <list>
                                <bean class="org.mortbay.jetty.webapp.WebAppContext">
                                        <property name="contextPath" value="/fileServer" />
                                        <property name="resourceBase" value="ResourcePath" />
                                        <property name="initParams">
                                            <map> 
                                               <entry key="org.mortbay.jetty.servlet.Default.dirAllowed" value="false" />
                                            </map>
                                        </property>
                                </bean>

                            </list>
                        </property>
                    </bean>
                </list>
            </property>
        </bean>
    </property>
</bean>

现在我升级到Jetty 8.1.12并发现initParams不适用于org.eclipse。 jetty.webapp.WebAppContext.Now现在配置如下(带有dirAllowed注释掉)

Now I am upgrading to Jetty 8.1.12 and found that initParams is not available for org.eclipse.jetty.webapp.WebAppContext.Now present config is below (with dirAllowed commented out)

    <bean id="Server" class="org.eclipse.jetty.server.Server" init-method="start" destroy-method="stop">
    <property name="connectors">
        <list>
            <bean id="Connector" class="org.eclipse.jetty.server.nio.SelectChannelConnector">
                <property name="port" value="${tnplportal.jettyServer.httpPort}" />
            </bean>
        </list>
    </property>

    <property name="handler">
        <bean id="handlers" class="org.eclipse.jetty.server.handler.HandlerCollection">
            <property name="handlers">
                <list>
                    <bean id="contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection">
                        <property name="handlers">
                            <list>
                                <bean class="org.eclipse.jetty.webapp.WebAppContext">
                                    <property name="contextPath" value="/fileServer" />
                                    <property name="resourceBase" value="resourcePath" />
                                    <!-- <property name="initParams">
                                           <map>               
                                            <entry key="org.mortbay.jetty.servlet.Default.dirAllowed" value="false" />
                                           </map>
                                        </property> -->
                                </bean>

                            </list>
                        </property>
                    </bean>
                </list>
            </property>
        </bean>
    </property>
</bean>

有人能告诉我如何为Jetty 8.1.12设置dirAllowed属性

Can someone tell me how to set dirAllowed property for Jetty 8.1.12

我看到基于代码的服务器的帖子很少,例如这个

I saw few posts for code based servers like this

但我的服务器是基于弹簧的。如何使用基于弹簧的配置进行设置。

But my server is spring based. How do I set with spring based configuration.

推荐答案

从Jetty 6升级到Jetty 8需要您更新Jetty参考。

The upgrade from Jetty 6 to Jetty 8 requires you to update your Jetty references.

首先,您需要更新所有的指定类。该项目于6年前迁移到Eclipse Foundation,这导致强制包名称从 org.mortbay.jetty 更改为 org.eclipse.jetty

To start with, you'll need to update all of your named classes. The project moved to the Eclipse Foundation 6 years ago, this resulted in a mandatory package name change from org.mortbay.jetty to org.eclipse.jetty

然后,您需要更新各种设置器,使其与您尝试执行的操作相关。

Then you'll want to update the various setters to be relevant to what you are attempting to do.

建议你抓一份 Jetty Distribution tarball(或zip)并查看它附带的Jetty XML文件以获得一些灵感,同时还引用 Jetty 8 Javadocs 了解一些细节。

Would recommend that you grab a copy of the Jetty Distribution tarball (or zip) and check out the Jetty XML files that it comes with for some inspiration, while also referencing the Jetty 8 Javadocs for some details.

注意:Jetty 6在2010年是EOL。 Jetty 8在2014年底是EOL ,今年之后将不会再对Jetty 8进行更新。非常鼓励你现在一直升级到Jetty 9.

Note: Jetty 6 was EOL'd in 2010. Jetty 8 is EOL at the end of 2014, there will be no more updates to Jetty 8 after this year. Would highly encourage that you upgrade all the way to Jetty 9 now.

这篇关于在Jetty 8.1.12中将dirAllowed设置为false的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆