简体   繁体   English

如何摆脱扩张?

[英]how to get rid of the expansion?

Hi I help do I then took to myName parameter was no extension, I have tried to do this with regular expressions:嗨,我帮忙做然后我把myName参数设置为没有扩展名,我试图用正则表达式来做到这一点:

String myName = request.getParameter("text").replaceFirst("[.][^.]+$", "");

But we did not help to make it)但我们没有帮助做到)

myName parameter takes the file names, I need to be without the help to do it Come listen to explain clearer: here I enter into the form (standard html form) the name of the file, it any, whether or indeks.html indeks.tht, myname parameter accepts that I have introduced, but he accepts it as indeks.html, and I need to accept it without permission, ie, an example I introduced indeks.html in shape, the servlet that I took introduced, and then it will print it, but I need that he derived no indeks.html, just index, I hope now it is clear, ie to be able to input form and indeks.html and index, and a servlet anyway find a file) myName参数取文件名,我需要在没有帮助的情况下去做 来听解释清楚:这里我在表单(标准 html 表单)中输入文件的名称,它任意,无论是 indeks.html 还是 indeks。 tht,myname参数接受我引入的,但他接受为indeks.html,我需要未经许可接受,即我在shape中引入indeks.html的一个例子,我引入的servlet,然后它将打印它,但我需要他导出的没有indeks.html,只是索引,我希望现在很清楚,即能够输入表单和indeks.html 和索引,并且无论如何找到一个servlet 文件)

I think i understood your trouble.我想我理解你的烦恼。 You're looking to strip (cut off) extension from a value that is passed through text parameter (example: .html, .gif, .jpeg您希望从通过文本参数传递的值中去除(切断)扩展名(例如:.html、.gif、.jpeg

This should help you.这应该对你有帮助。 ( it cuts the value from first character Up to the first "." (它将值从第一个字符向上剪切到第一个“。”

  String myName = request.getParameter("text").substring(0, str.indexOf(".");

Please beware that that some characters are special and can appear encoded.请注意,有些字符是特殊的,可能会出现编码。

See this helpful chart: http://www.ascii.cl/htmlcodes.htm请参阅此有用的图表: http : //www.ascii.cl/htmlcodes.htm

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM