jQuery的FormData不与Servlet一起工作[复制](jquery FormData not working with Servlet [duplicate])
这个问题在这里已经有了答案:
我使用jQuery FormData将一个文件发送到tomcat服务器。 该文件正在服务器上成功接收,但没有收到我用该文件发送的任何其他值。 为了处理文件上传,我使用了http://commons.apache.org/proper/commons-fileupload/和http://commons.apache.org/io/ 。 它以某种方式获取我的文件。 但是,当我写
request.getParameter("file")
在下面的代码的servlet中,它返回null。 即使它不显示请求对象中的任何参数。 我不明白它是如何获得文件。 任何人都可以帮我解决这个问题吗?
$('#uploadCourseDetail').click(function() { var form_data = new FormData(); if (!($('#courseDetails').prop('files')[0] == undefined)) { var file_data = $('#courseDetails').prop('files')[0]; form_data.append('file', 'examdetail'); form_data.append('courseDetails', file_data); } $.ajax({ url: 'Exam_TimeTable_Scheduler_bySlots_Web_Project/FileUploadServlet', type: 'POST', contentType: false, processData: false, cache: false, data: form_data, success: function(data) { alert("File Uploaded Successfully !"); } }); });
This question already has an answer here:
I am sending one file to the tomcat server using jQuery FormData. The file is being received successfully on the server but any other value which I send with the file is not being received. For processing the file upload, I am using http://commons.apache.org/proper/commons-fileupload/ and http://commons.apache.org/io/. It is getting my file somehow. But when I write
request.getParameter("file")
in the servlet for the below code, it returns null. Even it doesn't show any parameter in the request object. I don't understand how it gets the file then. Can anyone help me to solve this?
$('#uploadCourseDetail').click(function() { var form_data = new FormData(); if (!($('#courseDetails').prop('files')[0] == undefined)) { var file_data = $('#courseDetails').prop('files')[0]; form_data.append('file', 'examdetail'); form_data.append('courseDetails', file_data); } $.ajax({ url: 'Exam_TimeTable_Scheduler_bySlots_Web_Project/FileUploadServlet', type: 'POST', contentType: false, processData: false, cache: false, data: form_data, success: function(data) { alert("File Uploaded Successfully !"); } }); });
I use firebug to track the requests. It shows that both the fields are being sent to the server. Below is the snapshot for the same:
原文:https://stackoverflow.com/questions/43258751
最满意答案
VSTS Wiki现在支持使用#引用工作项 。 您可以键入#并引用现有工作项。 此功能刚刚完成,并且在我输入时仍在部署。
很快,您就可以将维基链接到工作项。 想象一下这个功能,当你在维基页面上推荐史诗的每个特征时,你可以跟踪你的史诗完成百分比。
您可以尝试分享您的反馈。
VSTS Wiki now supports referencing work items using #. You can type # and reference an existing work item. This feature has just been completed and is still being deployed as I type.
Very soon, you will be able to link a wiki to a work item. Imagine this feature allowing you to track what % of your epic is completed when you refer each feature of the epic on your wiki page.
You can try and share your feedback.
相关问答
更多-
只需看看将Git存储库发布到wiki的先决条件 : 您必须具有创建存储库的权限才能将代码发布为wiki。 默认情况下,为Project Administrators组的成员设置此权限。 任何有权贡献Git存储库的人都可以添加或编辑Wiki页面。 任何有权访问团队项目的人,包括利益相关者 ,都可以查看Wiki。 关于利益相关者维基访问的描述: 项目中的利益相关者可以阅读维基页面并查看修订, 但是他们无法执行任何编辑操作 。 例如,利益相关者无法创建,编辑,重新排序或还原对页面的更改。 注意: 具有利益相关者访 ...
-
从VSTS中的工作项检索“集成在构建中”链接类型(Retrieve “Integrated in build ” link type from workitems in VSTS)[2022-06-18]
您可以通过REST API获取开发链接以获取工作项关系: GET https://account.visualstudio.com/DefaultCollection/_apis/wit/workitems/{workitem ID}?$expand=relations&api-version=1.0 然后,您可以通过输出获取ArtifactLinks中的开发链接。 而Microsoft.VSTS.Build.IntegrationBuild字段不能用于获取VSTS的构建链接 ,因为Microsoft.V ... -
应该在TFS服务器中为WIT定义进行一些自定义,以便为工作项分配组。 但是对于VSTS,现在没有任何方法可以自定义WIT定义。 这意味着您无法将工作项分配给VSTS中的组。 您只能将工作项分配给有效用户。 There should be some customization made for the WIT Definition in your TFS server what allow the group to be assigned for Work Items. But for VSTS, there ...
-
版本控制路径长度限制均适用于VSTS和TFS。 在文章命名限制和约定 (除了部分Team Foundation Build(仅限本地TFS) )之外,所有限制均适用于TFS和VSTS。 因为它列出了适用于以下产品和产品的版本: 在VSTS和TFS中集成了两个版本控制系统: Git和TFVC (Team Foundation版本控制) 。 对于Team Foundation版本控制部分,它显示了TFVC VCS的限制(都可用于TFS和VSTS)。 所以,如果您使用TFVC来管理您的源代码,您可以找到文章中列出 ...
-
VSTS允许一个分支(VSTS Permission to one branch)[2021-11-01]
实际上, 利益相关者访问级别的人员不能在分支机构上工作。 为需要输入错误,查看待办事项,板卡,图表和仪表板但没有TFS CAL的用户分配利益相关者访问权限。 利益相关者还可以查看版本并管理版本批准。 利益相关者访问是免费的。 来源链接: 关于访问级别 有关利益主体可用功能的详细信息,请参阅利益相关方访问 用户应具有基本访问权限或包含代码功能的VS Enterprise 。 此外,它能够禁止他看到你在VSTS上的任何其他项目。 这是VSTS中称为权限的另一个概念。 不要将他添加到任何其他项目团队组中,期望他将 ... -
UI查询结果中没有显示链接类型的功能。 您可以通过REST API获取它: 运行存储的查询 There isn’t such feature to display link type in UI Query Result. You can get it through REST API: Run a stored query
-
VSTS - 工作项目(VSTS - Work Items)[2024-04-04]
对于第一个查询,您可以添加一个自定义字段,其中Allow assigning to groups所选Allow assigning to groups 。 这样,你可以分配给一个组: 有用的链接: https://docs.microsoft.com/en-us/vsts/work/customize/process/customize-process-field?view=vsts For your first query, you could add a custom field with Allow ... -
VSTS Wiki现在支持使用#引用工作项 。 您可以键入#并引用现有工作项。 此功能刚刚完成,并且在我输入时仍在部署。 很快,您就可以将维基链接到工作项。 想象一下这个功能,当你在维基页面上推荐史诗的每个特征时,你可以跟踪你的史诗完成百分比。 您可以尝试分享您的反馈。 VSTS Wiki now supports referencing work items using #. You can type # and reference an existing work item. This feature ...
-
使用WIQL,如何在System.Tags上查询VSTS工作项(Using WIQL, how do you query VSTS Work Items on System.Tags)[2023-02-03]
好吧,在我放弃和发布之后,我想通了。 我错误地使用了Contains。 我在括号中有过滤器。 以下两个示例现在都有效。 Select [System.Id], [System.Title], [System.State], [System.Tags] From WorkItems Where [State] <> 'Closed' AND [State] <> 'Removed' AND [Tags] Contains 'User Generated' AND [System.WorkItemType] = ... -
我可以将拉取请求链接到其他VSTS帐户中的工作项吗?(Can I link a pull request to a work item in a different VSTS account?)[2022-09-08]
不,VSTS仅针对同一VSTS帐户提取请求链接的工作项。 这是因为我们可以在帐户中添加其他帐户,因此该帐户代表整个项目的所有连接。 对于您的情况,您需要在公司帐户中添加团队 ,而不是创建新帐户。 在新增的团队中,您仍然可以使用公司帐户其他团队的工作项。 No, VSTS pull request linked work items only for the same VSTS account. That’s because we can add other accounts in the account, ...