主题:struts 传参数问题。。。急~~~~
struts_config.xml如下:
<struts-config>
<data-sources />
<form-beans >
<form-bean name="loginForm" type="org.apache.struts.action.DynaActionForm">
<form-property name="password" type="java.lang.String" />
<form-property name="username" type="java.lang.String" />
</form-bean>
</form-beans>
<global-exceptions />
<global-forwards >
<forward
name="fail"
path="/fail.jsp"
redirect="true" />
<forward
name="success"
path="/main.jsp"
redirect="true"/>
</global-forwards>
<action-mappings >
<action
attribute="loginForm"
input="/login.jsp"
name="loginForm"
path="/login"
scope="request"
type="com.dw.struts.action.LoginAction" />
</action-mappings>
<message-resources parameter="com.dw.struts.ApplicationResources" />
</struts-config>
loginaction.java如下:
/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package com.dw.struts.action;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.DynaActionForm;
import com.dw.hibernate.Test;
/**
* MyEclipse Struts
* Creation date: 09-29-2008
*
* XDoclet definition:
* @struts.action path="/login" name="loginForm" input="/login.jsp" scope="request" validate="true"
*/
public class LoginAction extends Action {
/*
* Generated Methods
*/
/**
* Method execute
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
DynaActionForm loginForm = (DynaActionForm) form;
String username = (String)loginForm.get("username");
String password = (String)loginForm.get("password");
Test t = new Test();//读取数据库的一个文件
if(t.getall(username, password)){//验证用户名是否存在
return mapping.findForward("success");
}
return mapping.findForward("fail");
}
}
现在想做一个显示在main.jsp中:得到用户名usernmae
就是不知道如何将action中的username传到 jsp页面中?高手指点~~~~
<struts-config>
<data-sources />
<form-beans >
<form-bean name="loginForm" type="org.apache.struts.action.DynaActionForm">
<form-property name="password" type="java.lang.String" />
<form-property name="username" type="java.lang.String" />
</form-bean>
</form-beans>
<global-exceptions />
<global-forwards >
<forward
name="fail"
path="/fail.jsp"
redirect="true" />
<forward
name="success"
path="/main.jsp"
redirect="true"/>
</global-forwards>
<action-mappings >
<action
attribute="loginForm"
input="/login.jsp"
name="loginForm"
path="/login"
scope="request"
type="com.dw.struts.action.LoginAction" />
</action-mappings>
<message-resources parameter="com.dw.struts.ApplicationResources" />
</struts-config>
loginaction.java如下:
/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package com.dw.struts.action;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.DynaActionForm;
import com.dw.hibernate.Test;
/**
* MyEclipse Struts
* Creation date: 09-29-2008
*
* XDoclet definition:
* @struts.action path="/login" name="loginForm" input="/login.jsp" scope="request" validate="true"
*/
public class LoginAction extends Action {
/*
* Generated Methods
*/
/**
* Method execute
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
DynaActionForm loginForm = (DynaActionForm) form;
String username = (String)loginForm.get("username");
String password = (String)loginForm.get("password");
Test t = new Test();//读取数据库的一个文件
if(t.getall(username, password)){//验证用户名是否存在
return mapping.findForward("success");
}
return mapping.findForward("fail");
}
}
现在想做一个显示在main.jsp中:得到用户名usernmae
就是不知道如何将action中的username传到 jsp页面中?高手指点~~~~