在spring控制器中无法正确读取jsp request参数中的特殊字符 [英] Special characters in jsp request parameter are not read properly in spring controller
问题描述
我正在尝试在jsp请求参数中发送一些参数,该参数包含特殊字符,例如#",例如:
i am trying to send some parameter in jsp request parameter which contains special character like '#' Ex:
http://localhost:8080/studentenrollmentsystem/editenrolment?id=3&course=C#&name=YASHIKA&dob=1986-12-22 00:00:00.0
在spring控制器中,当我尝试访问名为Course的参数时,它仅针对C#给出C,并且未捕获name参数.请帮助我如何正确实现此功能.
In the spring controller when i try to access the parameter named course it gives only C in respect of C# plus the name parameter is not captured. please help how can i implement this functionality properly.
推荐答案
使用<spring:url>
标记.
在JSP顶部指定taglib指令(如果尚未指定):
Specify the taglib directive at the top of your JSP (if not already specified):
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
然后您就可以使用它了:
And then you can use it something like this:
<spring:url value="http://localhost:8080/studentenrollmentsystem/editenrolment?id=3&course={course}&name=YASHIKA&dob=1986-12-22 00:00:00.0">
<spring:param name="course" value="C#"/>
</spring:url>
将课程拆分为<spring:param>
将确保其被逃脱-因此完整的URL如下所示:
Splitting out the course as a <spring:param>
will ensure it gets escaped - and so the full URL will look like:
http://localhost:8080/studentenrollmentsystem/editenrolment?id=3&course=C%23&name=YASHIKA&dob=1986-12-22 00:00:00.0
有关标签库的更多信息此处.
More info on the tag library here.
这篇关于在spring控制器中无法正确读取jsp request参数中的特殊字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!