我可以以某种方式打印作为参数传递给jsp的字符串吗?假设我有行动:package com.test;
public class TestAction extends Action {
String foo="bar";
@Override
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
//request.setParameter("foo", doo); // this does not work, I would like to achieve it.
return mapping.findForward("sql");
}
}
和jsp文件:
<!DOCTYPE html>
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8" %>
<%@page import="com.test.TestAction" %>
<%= request.getParameter("foo") %>
我在 struts-config.xml 中定义了:
<action
name="loginForm"
path="/login"
scope="request"
type="com.test.com.test.TestAction"
validate="false">
<forward name="sql" path="/index.jsp" />
</action>
我可以做吗?