开发者

Applet parameter contains back slash.

When i define either one of the parameters below in a html page which starts th开发者_StackOverflowe applet:

<param name=testParam value=test\\test> 
<param name=testParam value='test\\test'>

applet.getParameter("testParam") method returns value as "test\\test". In my logic it should return "test\test".(for value=test\test then method returns "test\test") How is this possible? is it something relating to the encoding or something that java handles when it gets output.


Java requires back-slashes to be escaped. HTML does not.

E.G.

/* <applet
    code='TestParam'
    width='200'
    height='30'>
<param name='path' value='test\test'>
</applet> */
import javax.swing.*;

public class TestParam extends JApplet {

    public void init() {
        JTextField output = new JTextField(getParameter("path"), 20);
        add(output);
        validate();
    }
}

Result

Applet parameter contains back slash.


Your string is defined in html not in java. In html there is no need to escape backslashes hence why you are getting "test\test". If you need to have it with one slash, then define the string with one slash.


There is no need to escape a single backslash in HTML.

http://www.cs.tut.fi/~jkorpela/www/revsol.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜