如何从jython的URL中删除.py [英] how to remove .py from the url in jython

查看:95
本文介绍了如何从jython的URL中删除.py的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从URL中删除.py扩展名,我正在使用此教程:

I am trying to remove .py extension from the url, I am using this tutorial: http://www.jython.org/jythonbook/en/1.0/SimpleWebApps.html

我的web.xml如下:

my web.xml is as follows:

   <?xml version="1.0" encoding="UTF-8"?>

<web-app version="2.4"
         xmlns="http://java.sun.com/xml/ns/j2ee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
         http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" >


    <servlet>
        <servlet-name>PyServlet</servlet-name>
        <servlet-class>org.python.util.PyServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>PyServlet</servlet-name>
        <url-pattern>*.py</url-pattern>
    </servlet-mapping>

    <servlet>
        <servlet-name>NewJythonServlet</servlet-name>
        <servlet-class>NewJythonServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>NewJythonServlet</servlet-name>
        <url-pattern>/NewJythonServlet</url-pattern>
    </servlet-mapping>

    <servlet>
        <servlet-name>NewJavaServlet</servlet-name>
        <servlet-class>NewJavaServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>NewJavaServlet</servlet-name>
        <url-pattern>/NewJavaServlet</url-pattern>
    </servlet-mapping>

    </web-app>

我也曾尝试将/*放在网址映射中.但是它给了错误! 有人可以为此指导我吗.

I have also tried putting /* in url mapping..but its giving error! Can someone guide me for this.

谢谢

当我将/*放在url映射中时,这就是我得到的:

Here is what i get when i put /* in url mapping:

HTTP Status 404 - /jythonapp/NewJythonServlet

type Status report

message /jythonapp/NewJythonServlet

description The requested resource (/jythonapp/NewJythonServlet) is not available.

Apache Tomcat/6.0.30

推荐答案

我想知道是否需要在"servlet映射"部分中指定"jythonapp"文件夹.

Im wondering if the 'jythonapp' folder needs to be specified in the 'servlet-mapping' section.

EG:

<url-pattern>/jythonapp/NewJythonServlet</url-pattern>

(我认为那不是很对,但是自从我使用Tomcat以来已经有一段时间了.)

(I don't think that's quite right but its been a while since I've used Tomcat. )

我还认为'jythonapp'文件夹应该是'webapps'的子目录. -> http://www.sethanil.com/ot/10

Im also thinking that the 'jythonapp' folder should be a sub of 'webapps'. --> http://www.sethanil.com/ot/10

此测试使用的是哪个URL?

What URL are you using for this test?

这篇关于如何从jython的URL中删除.py的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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