How to pass a string containing double quotes from a jsp to a servlet through URL using get method

前端 未结 3 1048
日久生厌
日久生厌 2021-01-21 05:33

I want to set a jsp parameter to an attribute value which may contain special symbols, then use a form GET submit to pass the parameter to a servlet controller. For

3条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-21 06:14

    You encode the value before placing it into the form and then decode it in the serlvet.

    (You might have already seen this as %20 in URL parameters)

    Here are the respective classes.

    http://download-llnw.oracle.com/javase/1.5.0/docs/api/java/net/URLEncoder.html

    http://download-llnw.oracle.com/javase/1.5.0/docs/api/java/net/URLDecoder.html

提交回复
热议问题