你提交表单就指向action了
再action中可以用request.getpamter(“变量名”);
就ok了
再action中可以用request.getpamter(“变量名”);
就ok了
解决方案 »
- [求助]BAT访问 jar时找不到JDBC驱动
- 关于Criteria模糊查询及分页
- 急救啊~!先谢谢了~~换成java语言表达~
- Caused by: org.hibernate.AnnotationException: Property of @IdClass not found in
- 怎么解决java.sql.SQLException: I/O Error: Connection reset by peer: socket write error
- 很高深的eclipse插件问题
- 在Struts中如何向数据库添加数据
- 非常烦的cmr问题
- 从后台返回的json数据到页面要不要eval("("+data+")")一下然后在页面展示啊
- 关于wait和notify的问题
- 如何用JAVA把数据批量从oracle中取出,再批量地插入到mysql中
- 移植了petstore,高兴与你共享!
还可以,再action中httpServletRequest.setAttribute("photopath", photopath);
再jsp中request.getAttribute("photopath");
比如说
http://localhost:8080/teststruts/test.do?a=name
那么在在Action的
execute(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse)
函数里面有一个httpServletRequest参数。可以通过httpServletRequest.getParameter("a");来获取值。
如果jsp传过来的是表单上的值,也可以通过ActionForm来获取变量值
具体可以看看csdn上的文章。
1.自定义BEAN需要在action servlet中用setAttribute语句set一下,在jsp中使用<jsp:useBean id="infobean" scope="request" class="mybean.infobean" />来使用.2.form bean需要在struts-config.xml中定义,如下:
struts-config.xml中:
<!-- ========== Form Bean Definitions =================================== -->
<form-beans>
<form-bean name="bean" type="formbean.bean"/>
</form-beans><action path="/gotoresult"
type="resultaction"
name="bean"
scope="request"
validate="true"
input="menu.jsp">
<forward name="success" path="/jsp/result.jsp"/>
</action>jsp中:
<html:form name="bean" type="formbean.bean" action="/gotoresult.do">
这样在jsp提交时就能将画面上的数据放到bean中去了,在resultaction这个action servlet中可以拿到!