我正在努力要求从URL中显示(使可读的)字符.
当我使用谷歌浏览器时,它会以中文显示参数 - 即使它们被编码为UTF-8.
当我使用Mozilla Firefox时,它会以中文显示参数 - 即使它们被编码为UTF-8.
当我使用Internet Explorer时,它显示以UTF-8编码的参数.
NB URL编码为UTF-8; 我知道,因为当我从其中三个中复制URL并将其粘贴到Notepad ++时,其中三个显示以下内容:
/%E6%89%93%E5%BC%80%E7%9B%AE%E5%BD%95 /%E7%9B%B8%E6%9C%BA /%E6%95%B0%E7%A0% 81%E7%9B%B8%E6%9C%BA /%E5%B0%8F%E5%9E%8B%E6%95%B0%E7%A0%81%E7%9B%B8%E6%9C%BA /的PowerShot-A480/p/1934793
可能是Mozilla Firefox和Google Chrome家伙有这样的改进,可以使编码的字符串可读,也许IE的人不支持吗?或者,有没有办法用IE激活它?
顺便说一句......转到视图>>编码>> Unicode(UTF-8)负责页面内部的文本,但不会对URL中的文本产生任何影响.
任何帮助将不胜感激!
我需要转义字符以避免 XSS。我正在使用 org.apache.commons.lang.StringEscapeUtils.escapeHtml(String str),它通过以下方式提供帮助:
原始输入
" onmouseover=alert() src="
Run Code Online (Sandbox Code Playgroud)
转义 HTML 后变成
" onmouseover=alert() src="
Run Code Online (Sandbox Code Playgroud)
但是,在某些情况下,反射的输入会被单引号捕获,例如:
test'];}alert();if(true){//
Run Code Online (Sandbox Code Playgroud)
在这种特殊情况下,转义 HTML 不会产生任何效果。然而,org.apache.commons.lang.StringEscapeUtils 还有一个名为 escapeJavascript(String str) 的方法,它将输入转换为:
test\'];}alert();if(true){\/\/
Run Code Online (Sandbox Code Playgroud)
这里的问题是,你会先转义 HTML 然后转义 Javascript 来清理你的输入吗?另一种方法是手动用 \' 替换单引号字符。
任何帮助将不胜感激!
我正在努力将项目从Ant迁移到Maven.我需要提供的最终发行版是一个包含可执行jar的zip,其中包含所有依赖性.这是我的pom的一部分:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-4</version>
<configuration>
<finalName>ProjectDistribution</finalName>
<appendAssemblyId>false</appendAssemblyId>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>fullQualifiedNameToMainClass</mainClass>
<addClasspath>true</addClasspath>
</manifest>
</archive>
<descriptors>
<descriptor>${project.basedir}/src/main/assembly/dep.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>jar-with-dependencies</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
<execution>
<id>dist</id>
<phase>assembly</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
这是汇编文件:
<assembly>
<id>dist</id>
<formats>
<format>zip</format>
</formats>
<!-- 1st approach-->
<!--files>
<file>
<source>
/target/ProjectDistribution.jar
</source>
<outputDirectory>/</outputDirectory>
</file>
</files-->
<fileSets>
<!-- 2nd approach-->
<!--fileSet>
<directory>/target</directory>
<outputDirectory></outputDirectory>
<includes>
<include>*.jar</include>
</includes>
</fileSet-->
<fileSet>
<directory>/HelpFiles</directory>
<outputDirectory></outputDirectory>
<includes>
<include>*.*</include>
</includes>
</fileSet>
</fileSets>
Run Code Online (Sandbox Code Playgroud)
我运行1.- mvn compile,2.- mvn package和3.- mvn …