我开发了 demopro-dispatcher-servlet.xml 和 示例代码是
<mvc:interceptor>
<mvc:mapping path="/login/**" />
<ref bean="loginInterceptor" />
</mvc:interceptor>
<bean id="loginInterceptor" class="com.demo.interceptor.LoginInterceptor" />
我的 LoginInterceptor 示例代码是
private static String[] SERVLET_PATHS = {
"/login/email/password"
.. }
我的 LoginController 示例代码是
@Controller
@RequestMapping("login")
public class LoginController{
......
@RequestMapping("/email/password/{email:.+}/{password:.+}")
@Transactional
public @ResponseBody void authenticationForLogin(@PathVariable String email, @PathVariable String password, HttpServletRequest request,
HttpServletResponse response) {
//i tried this code
/*
String restOfTheUrl1 = (String) request.getAttribute(
HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE);
logger.debug("Here password is : "+password+" : "+restOfTheUrl1);
*/
logger.debug("Here password is : "+password);
//Its print demo!@ but input is demo!@#$%^
我的请求网址:&#34; http:localhost:8080 / demopro / login / email / password / {email} / {password} &#34;
来自帖子的人调用网址:&#34; http:localhost:8080 / demopro/login/email/password/acecd@gmail.com/demo!@#$%^ &#34;
密码打印,如演示!@
答案 0 :(得分:0)
当您传递敏感数据(如电子邮件和密码)时,建议您在此处使用网址编码/解码。您需要从UI传递已编码的网址,然后在控制器中将其解码为
String result = URLDecoder.decode(url , "UTF-8");