struts 表单提交问题?

dabaishaflyw 2009-02-07 06:36:36
<script>
function validate(type){
if(type=="submit")
{
document.hrjobform.action="${contextPath}/job.do?method=saveResumeInfo";
document.hrjobform.target="_self";
}else
{
document.hrJobForm.target="_blank";
}
//简历预览
document.hrJobForm.submit();
}
<script>
<html:form styleId="hrJobForm" action="${contextPath}/job.do?method=getResumeView" method="post" enctype="multipart/form-data">
</html:form>

<input type="button" name="button1" value="预览" class="button-search" onclick="validate('view')" />
<input type="button" name="button2" value="提交" class="button-font2" onclick="validate('submit')"/>
问题描述如下:
<html:form>标签中如何通过js来控制表单提交?动态改变action的内容?开始我是用普通的form表单提交的,后来要上传图片,觉得用struts表单提交更简单些,但是此时我不能够改变action 的内容了?请大家帮帮我吧。
...全文
126 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
dabaishaflyw 2009-02-09
  • 打赏
  • 举报
回复
不好意思各位,是我页面上没引struts标签库。楼上的都有分
zhj92lxs 2009-02-08
  • 打赏
  • 举报
回复
document.hrJobForm.action="${contextPath}/job.do?method=saveResumeInfo";
document.hrJobForm.target="_self";

cavis 2009-02-08
  • 打赏
  • 举报
回复
<html:form styleId="hrJobForm" action="${contextPath}/job.do?method=getResumeView" method="post" enctype="multipart/form-data">
</html:form>

${contextPath}/

enctype="multipart/form-data
这是什么东西?
fosjos 2009-02-08
  • 打赏
  • 举报
回复
你先看看struts生成的html代码如何,用不用struts没有本质的区别
dabaishaflyw 2009-02-08
  • 打赏
  • 举报
回复
document.forms[0].action=" <%=request.getContextPath()%>/job.do";
document.forms[0].submit();
我这么写,在普通form表单是可以的,但是在struts的表单中,报document.forms.0为空或不是对象?这个是怎么回事呢?我ie7.0下的测试
dabaishaflyw 2009-02-08
  • 打赏
  • 举报
回复
谢谢各位,
document.forms[0].action="<%=request.getContextPath()%>/job.do";
document.forms[0].submit();
我都实验过了,我的jsp页面好像不支持这么写。今天是周末,明天到公司在试试看。

East271536394 2009-02-08
  • 打赏
  • 举报
回复
enctype="multipart/form-data
这是一种格式,
一般就是在上传文件中用到
East271536394 2009-02-08
  • 打赏
  • 举报
回复
enctype="multipart/form-data
这是一种格式,
一般就是在发邮件的表单中用到这个

fulianglove 2009-02-08
  • 打赏
  • 举报
回复

document.forms[0].action="<%=request.getContextPath()%>/job.do";
document.forms[0].submit();

forms[0]表示的页面上的form组成的数组,提交第一个form(一般只有一个form)的话就是forms[0]。
想提交哪个,改变数组索引就好
jabeginner 2009-02-08
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 cavis 的回复:]
<html:form styleId="hrJobForm" action="${contextPath}/job.do?method=getResumeView" method="post" enctype="multipart/form-data">
</html:form>

${contextPath}/

enctype="multipart/form-data
这是什么东西?
[/Quote]

在js中提交可以就这么做
fosjos 2009-02-07
  • 打赏
  • 举报
回复
document.hrjobform.action名称写错了
楼主主要是没明白struts的本质,其实是分成两部分:服务端->客户端,客户端->服务端

前者将html:form解析成<form> ,可以看看生成的网页的html代码
后者是将提交的form封装成actionForm

所以只要你写的<form>和用html:form生成的<form>格式规范相同,提交还是一样的

67,514

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧