Struts2: How can I tell my index.jsp to switch to struts2 action?

Often when I see index.jsp in a web application, it just goes to another url like login.jsp like

<jsp:forward page="login.jsp" /> 

When using struts2, I need a similar index.jsp, but I want it to go to action. How to do it?

+4
source share
3 answers

You can use plain HTML if you want

Between your tags use:

  <META HTTP-EQUIV="Refresh" CONTENT="1;URL=Login.action"> 

This will be redirected to myCOntext / Login.action

If Login is outside the namespace, you need to include it in the URL

+12
source

scriptlet:

 <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <% response.sendRedirect("/Project/namespace/Login.action"); %> 

I use it with Struts2 and it works.

+3
source

Try the following:

 <META HTTP-EQUIV="Refresh" CONTENT="0;URL=welcomeLink.action"> 

It is also a worker,

 <% response.sendRedirect("welcomeLink.action"); %> 

But in my experience, it will only work when it is on the index page or on any other page that loads as the first page.

If I put response.sendRedirect on any successor page, this will not work. Extract this question

+3
source

Source: https://habr.com/ru/post/1314832/


All Articles