我试图在点击提交按钮时调用动作类中存在的方法但是方法没有被调用。 这是我的代码---这是jsp页面
<body>
<s:form method="POST" >
<a href="<s:url action="goback"/>">click here to go back</a>
<s:submit action="fileUploadAction" value="UploadFile"/>
<s:file name="fileUpload" label="Select a File to upload" size="40"/>
</s:form>
</body>
这是struts.xml
<struts>
<package name="default" extends="struts-default">
<action name="fileUploadAction" class="com.cdac.cloud.HelloWorld" method="uploadFile">
<result name="successfulupload">/success.jsp</result>
<result name="exception">/error.jsp</result>
</action>
</package>
</struts>
之前这个提交按钮是在另一个页面,它工作正常,但当我把它移动到另一个jsp页面问题开始
答案 0 :(得分:0)
<body>
<s:form action="fileUploadAction">
<a href="<s:url action="goback"/>">click here to go back</a>
<s:submit value="UploadFile"/>
<s:file name="fileUpload" label="Select a File to upload" size="40"/>
</s:form>
</body>
答案 1 :(得分:0)
试试这个..!
<body>
<s:form name="something">
<a href="<s:url action="goback"/>">click here to go back</a>
<s:submit onclick="javascript:submit();"/>
<s:file name="fileUpload" label="Select a File to upload" size="40"/>
</s:form>
</body>
然后在JS,
function submit()
{
document.something.action="<%= request.getContextPath()%>/fileUploadAction";
document.something.submit();
}
我没有测试这段代码..!发表评论,如果它正在运作..!