2013-05-03 79 views
1

我有一个登录页面,欢迎页面通会话ID的URL jsp页面在Struts 2

这里是struts.xml文件

<?xml version="1.0" encoding="UTF-8" ?> 
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd"> 
<struts> 

<constant name="struts.devMode" value="true" /> 
<constant name="struts.enable.DynamicMethodInvocation" value="true"/> 
<constant name="struts.objectFactory" value="org.apache.struts2.spring.StrutsSpringObjectFactory" /> 

<package name="Authentiate" extends="struts-default"> 

<global-results> 

<result name="error">/error.jsp</result> 

</global-results> 

<action name="loginAuthenticate*" class="com.authenticate.actions.LoginAuthenticate" method="{1}"> 

<result name="success">/welcome.jsp</result> 
<result name="redirectRegister" type="redirect">/registration.jsp</result> 

</action> 

</package> 

</struts> 

如何可以追加会话ID为welcome.jsp当我从动作返回成功类struts.xml,如下

http://myopenidhost.com/openid/welcome.jsp?sessionid=swe234323xghf346rrg34r4

回答

-2

如果您正试图把你的登录DET苦恼的到会话,使用SessionAware接口,如果没有的话让我知道..

+0

我喜欢将查询字符串追加到结果页面...作为http://myopenidhost.com/openid/welcome.jsp?name=hello&user=pavan – pavan 2013-05-03 03:31:20

0

在这种情况下,当你提交你的JavaScript函数下方的页面使用:

,你会在你的页面声明隐藏字段,并分配从你的动作jsessionId到这个隐藏的。

function abc(){ 

    var jsessionId=document.<hiddenFieldName>.value; 
    document.action="welcomePage.jsp?sessionId="+jsessionId; 
    document.submit(); 

} 

我不知道什么是你想实现,但其雅阿一种Get请求的,你可以看到这个生成的ID在你的URL

如果我没看错,这是方式在URL中附加值.. 请让我知道这是否有帮助...如果不是,我需要准确的标准,你想实现什么。

+0

http://myopenidhost.com/openid/welcome。 jsp?name = hello&user = pavan我如何得到上面的页面,因为我使用了result type = success,并且只是调用了welcome.jsp,但我无法附加查询字符串。 – pavan 2013-05-03 04:15:01

+0

Pavan,你能告诉我你的标准吗?我想知道这样可以给你正确的解决方案...有几种方法可以做到这一点。我知道你想添加这些值,但是为什么和为了什么目的,如果你清除了这个。也许我会帮你。 – 2013-05-03 06:57:02

0

您应该配置的结果是,在操作返回参数

<result> 
    <param name="location">/welcome.jsp</param> 
    <param name="sessionId">${sessionId}</param> 
</result> 

你返回结果之前应该初始化参数

public class LoginAuthenticate extends ActionSupport { 

    private String sessionId; 

    public String getSessionId() { 
    return sessionId; 
    } 

    public String execute() { 

    //action code ... 

    sessionId = ServletActionContext.getRequest().getSession().getId(); 
    return SUCCESS; 
    } 
} 

你可以阅读更多有关结果here和有关动态效果here