Skip to content

Instantly share code, notes, and snippets.

@jvinceso
Created January 10, 2022 04:03
Show Gist options
  • Save jvinceso/5e4e38b281f12ad0881e2dc6b22be3d6 to your computer and use it in GitHub Desktop.
Save jvinceso/5e4e38b281f12ad0881e2dc6b22be3d6 to your computer and use it in GitHub Desktop.
Agregar cabeceras usando el contexto actual en respuestas mediante struts2
//Dependencias
import org.apache.struts2.StrutsStatics;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletResponse;
public String metodoprueba() throws Exception {
final String origen = "loginAccion.metodoprueba";
HttpServletResponse httpResponse =ServletActionContext.getResponse();
httpResponse.setHeader("Access-Control-Allow-Origin", "*");
httpResponse.setHeader("Access-Control-Allow-Methods", "POST, GET, PUT, OPTIONS, DELETE");
System.out.println("---CORS Configuration Completed---");
long time;
String result = new String();
result = "json";
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment