簡體   English   中英

如何匹配Django中任何url包含某個字符串(如.jsp)?

[英]How to match any url contains a certain string (such as .jsp) in Django?

我想軟拒絕任何包含字符串的路徑,例如.jsp 3 中的 .jsp。這是我的 url.py:

from django.urls import re_path
from django.views.generic import TemplateView

re_path(
    r"^.*\.jsp\??.*$",
    TemplateView.as_view(template_name="404.txt", content_type="text/plain"),
),

上面的路徑模式可以匹配一個普通的字符串,比如/whatever.jsp ,但是不能匹配下面的探測字符串。 如何改進我的 re_path 模式以匹配這個? 謝謝

/content/..%3B/crx/packmgr/list.jsp%3B%0A%3B%0A%3B%0A%3B%0A%3B%0A%3B%0A%3B%0A%3B%0A%3B%0A%3B%0A%3B%0A%3B%0A%3B%0A%3B%0A%3B%0A%3B%0Aa.css?_dc=1615863080856&_charset_=utf-8&includeVersions=true

這個正則表達式r"[^\.](.*)\.jsp(.*)"怎么樣

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM