I am trying to pass an URL from jsp to controller on a button submit
JSP Code:
<input type="button" onClick="window.location='<c:url value="/tools/serverLogs/${logsPath}/"/>'" name="serverLogsPage" value="View all logs"/>
Controller:
@RequestMapping(value="/tools/serverLogs/{logsPath}",method=RequestMethod.GET)
public String showLogs( Model m, @PathVariable String logsPath) {
return "tools/ServerLogs";
}
I tried passing the path in different formats, but i am getting error while going to the controller.
Example:
logsPath = "C:\\abc\\def\\ght";
logsPath = "C:\\abc\\def\\ght" (In this case i am not getting any error but in controller the path looks like C: abc def ght);
logsPath = "C://abc//def//ght";
logsPath = "file://abc/def/ght";
You could encode the logsPath before passing it on the view and decode it when retrieving content
logsPath = "C:\abc\def\ght";
logsPath = URLEncoder.encode(logsPath, "UTF-8"); // Or "ISO-8859-1"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.