我的网站应用程序(使用struts2创建)中注册的账户会获得一个独立的站点,如http://localhost/accountname。
每个帐户都有自己的登录页面。注册后,用户将获得一个单独的网站http://localhost/accountname。
我想首先扫描请求的URL(在struts2中)然后将该请求转发到相应的登录页面。
我该怎么做?请帮忙。
我的网站应用程序(使用struts2创建)中注册的账户会获得一个独立的站点,如http://localhost/accountname。
每个帐户都有自己的登录页面。注册后,用户将获得一个单独的网站http://localhost/accountname。
我想首先扫描请求的URL(在struts2中)然后将该请求转发到相应的登录页面。
我该怎么做?请帮忙。
您可以通过以下方式在您的操作方法中获取请求对象:
HttpServletRequest request = ServletActionContext.getRequest();
您可以通过如下方式找到请求的URL:
String spath = request.getServletPath();
然后您可以解析它并寻找您所需要的模式并相应地进行转发。
更新:
你们可以在休战队编队档案中使用包裹。 让我们说“使用者”。
<package name="userapps" extends="default" namespace="/userapps">
<action name="*" class="path.to.your.ActionClass" method="processUrl">
<result name="success" type="redirectAction">
<param name="actionName">userpage</param>
<param name="id">${user.id}</param>
</result>
</action>
</package>
在 ActionClass 的 processURL 方法中,您可以提取您感兴趣的 URL 部分,并设置一个属性,例如用户和他的 ID。然后,您可以从您的 action 返回 success。
您将拥有第二个动作,称为用户页面,它将获取用户的ID并转发到正确的页面。
现在,任何形式为localhost/myapp/userapps/anything.action的URL都将调用processURL方法。
Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...
Check this, List<String> list = new ArrayList<String>(); for (int i = 0; i < 10000; i++) { String value = (""+UUID.randomUUID().getLeastSignificantBits()).substring(3, ...
I am in the middle of solving a problem where I think it s best suited for a decorator and a state pattern. The high level setting is something like a sandwich maker and dispenser, where I have a set ...
I have been trying to execute a MS SQL Server stored procedure via JDBC today and have been unsuccessful thus far. The stored procedure has 1 input and 1 output parameter. With every combination I ...
I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...
If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...
I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....
I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...