我有一个Web应用程序,当用户点击个人资料链接时,如果他没有登录,我想将他重定向到登录页面,然后当他登录时,我会将他发回给他有的链接最初点击.
在这种情况下,他的个人资料.
我已经做了部分,直到将他重定向到登录页面,但我试图找出如何记住他的初始点击,并在他成功登录后重定向到此页面.
我正在使用Spring Security进行登录.
我正在使用Spring和Tomcat 7.0开发Web应用程序.当我在浏览器中测试页面时,它不会应用CSS,因为它无法加载外部样式表.
这是我的各种文件
web.xml中
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>MyProject</display-name>
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>ResourceServlet</servlet-name>
<servlet-class>org.springframework.js.resource.ResourceServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>*.htm</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>ResourceServlet</servlet-name>
<url-pattern>/resources/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>redirect.jsp</welcome-file>
</welcome-file-list>
</web-app>
Run Code Online (Sandbox Code Playgroud)
调度员servlet.xml中
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver"
p:prefix="/WEB-INF/jsp/" p:suffix=".jsp" />
<bean id="userService" class="com.abdus.service.UserServiceImpl" />
<context:component-scan base-package="com.abdus.web" />
<bean
class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" />
<bean
class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" />
</beans>
Run Code Online (Sandbox Code Playgroud)
这是来自jsp页面的头
welcomePage.jsp
<meta charset="utf-8"/>
<title>Welcome</title>
<link …Run Code Online (Sandbox Code Playgroud) 可能重复:
使用Spring Security时,获取bean中当前用户名(即SecurityContext)信息的正确方法是什么?
我正在使用spring security,我想知道如何在我的控制器中检索当前登录的用户名.我可以在某处存储与登录用户名相关联的用户ID吗?目前我从Priciple对象获取用户名
public boolean populateUserName(ModelMap model, Principal principal) {
if (principal != null) {
String name = principal.getName();
model.addAttribute("username", name);
System.out.println("userName - " + name);
return true;
}
else
{
System.out.println("principal is null");
return false;
}
}
Run Code Online (Sandbox Code Playgroud)
我在每个控制器方法中获取此Principal对象.我不知道这是否是获得它的最佳方式.例如,这是代码
@RequestMapping(value = "/secure/myitem.htm", method = RequestMethod.GET)
public ModelAndView showItem(@RequestParam("listingId") String listingId,
ModelMap model, Principal principal) {
populateUserName(model, principal);
}
Run Code Online (Sandbox Code Playgroud) 我一直在尝试使用Paypal Adaptive API解决以下问题.我已将Paypal Adaptive链式支付API与我的网站集成.当用户点击"pay with paypal"按钮时,需要向paypal网站付款.我的问题从这里开始
现在,我希望能够在用户成功付款时将各种付款信息列入我的数据库,并且在投入生产之前我没有正确的方法在开发中进行
我很惊讶像paypal这样的十亿美元公司可以为开发人员提供这样一个无用的代码来集成
我也看看这个答案,Adaptive Payments Paypal:没有数据的返回网址?.来自paypal的人说
当用户返回returnUrl端点时,您调用PaymentDetails API并检查状态并继续.
好吧问题是拨打PaymentDetails,我需要paytoken.我怎样才能从回归中获得收益?就像现在一样,返回URL没有任何查询参数.