如何在struts tile中获取原始url [英] how to get original urls in struts tiles
本文介绍了如何在struts tile中获取原始url的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经尝试过所有这些东西但是给了网址,比如
/get.do。我有两个forwaed页面成功和失败。如果成功我想要像.... / projectname / success.jsp那样的网址。我怎么能得到这个?
i使用了以下代码但没有工作。
i have tried with all these things but giving url like
/get.do. i have two forwaed pages success and failure.if success i want url like ..../projectname/success.jsp. how can i get this one
i have used the following code but none of working.
public class LoginAction extends Action {
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
String status;
String msg=null;
String originalURI=(String)request.getAttribute(org.apache.struts.Globals.ORIGINAL_URI_KEY);
System.out.println("originalurl========"+originalURI);
Loginform lf=(Loginform)form;
String name=lf.getName();
String pwd=lf.getPwd();
if(name.equals("swapna") && pwd.equals("swappna"))
{
status="success";
}
else
{
status="Failure";
}
//System.out.println("hfjkfhkfhef===="+ mapping.getPath());
String url=request.getAttribute("javax.servlet.forward.request_uri");
String url1=request.getAttribute("javax.servlet.forward.query_string")
System.out.println("path========-----"+url);
return mapping.findForward(status);
}
}
是有没有办法获得原始网址。
is there any way to get original url.
推荐答案
您好,
您可以通过以下方式获取实际网址使用类似于下面所示的代码。
Hello,
You can obtain the actual URL by using code similar to one shown below.
ActionForward af = mapping.findForward(status);
System.out.println("path========-----".concat(af.getPath()));
问候,
Regards,
这篇关于如何在struts tile中获取原始url的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文