gpt4 book ai didi

file - grails 3.3.9从输入获取文件

转载 作者:行者123 更新时间:2023-12-02 15:17:02 28 4
gpt4 key购买 nike

我目前在grails 3.3.9上有问题。
这是我的代码:

<g:uploadForm resource="${objetInstance}"role="form" method="POST" class="form-horizontal">

<g:actionSubmit action="update" class="btn green-meadow"
value="${message(code: 'enregistrer', 'default': 'Enregistrer')}"/>

<input type="file" name="myFile" id="myFile"
class="form-control"
value=""/>

</g:uploadForm>

在我的Controlle中,我尝试了:
def file = params.myFile

但我的文件为空。

与:
def file = request.getFile('myFile')

Caused by: groovy.lang.MissingMethodException: No signature of method: net.bull.javamelody.JspWrapper$HttpRequestWrapper3.getFile() is applicable for argument types: (java.lang.String) values: [myFile] Possible solutions: getXML(), getPart(java.lang.String), getAt(java.lang.String), getAt(java.lang.String), getLocale(), getJSON() at



向上:
要提供更多信息,这是我的构建gradle。我想我必须添加一个特定的插件来处理文件上传。

我试过了:编译'commons-fileupload:commons-fileupload:1.4'。但仍然存在相同的错误。我真的迷路了。任何的想法?
buildscript {
repositories {
mavenLocal()
maven { url "https://repo.grails.org/grails/core" }
maven { url "https://mvnrepository.com/artifact" }
maven { url "https://mvnrepository.com/artifact/org.keycloak/keycloak-spring-security-adapter" }
maven { url "https://mvnrepository.com/artifact/org.jboss.logging/jboss-logging" }
}
dependencies {
classpath "org.grails:grails-gradle-plugin:$grailsVersion"
classpath "com.bertramlabs.plugins:asset-pipeline-gradle:2.15.1"
classpath "org.grails.plugins:hibernate5:${gormVersion-".RELEASE"}"
classpath 'net.saliman:gradle-cobertura-plugin:2.5.4'
classpath "org.grails.plugins:views-gradle:1.2.8"
}
}

version "4.0.0_RC20"
group "myProject"

apply plugin: "eclipse"
apply plugin: "idea"
apply plugin: "war"
apply plugin: "org.grails.grails-web"
apply plugin: "org.grails.grails-gsp"
apply plugin: "asset-pipeline"
apply plugin: "net.saliman.cobertura"
apply plugin: "org.grails.plugins.views-json"
apply from: "gradle/sonar.gradle"

repositories {
mavenLocal()
maven { url "https://repo.grails.org/grails/core" }
maven { url "https://mvnrepository.com/artifact" }
maven { url "http://dl.bintray.com/dmahapatro/plugins" }
}

dependencies {

compile "com.warrenstrange:googleauth:1.1.2"
compile "com.google.zxing:core:3.3.1"
compile "com.google.zxing:javase:3.3.1"
compile 'org.grails.plugins:grails-spring-websocket:2.4.1'

compile "org.springframework.boot:spring-boot-starter-logging"
compile "org.springframework.boot:spring-boot-autoconfigure"
compile "org.grails:grails-core"
compile "org.springframework.boot:spring-boot-starter-actuator"
compile "org.springframework.boot:spring-boot-starter-tomcat"
compile "org.grails:grails-dependencies"
compile "org.grails:grails-web-boot"
compile "org.grails.plugins:cache"
compile "org.grails.plugins:scaffolding"
compile "org.grails.plugins:hibernate5"
compile "org.hibernate:hibernate-core:5.1.16.Final"
compile "org.hibernate:hibernate-ehcache:5.1.16.Final"

testCompile "org.grails:grails-datastore-gorm-test:$gormVersion"
console "org.grails:grails-console"
profile "org.grails.profiles:web"
runtime "com.bertramlabs.plugins:asset-pipeline-grails:2.15.1"
runtime "com.h2database:h2"
testCompile "org.grails:grails-plugin-testing"
testCompile "org.grails.plugins:geb"
testRuntime "org.seleniumhq.selenium:selenium-htmlunit-driver:2.47.1"
testRuntime "net.sourceforge.htmlunit:htmlunit:2.18"

runtime 'org.apache.tomcat:tomcat-jdbc'

compile 'org.grails:grails-logging'

//postgresql
provided 'org.postgresql:postgresql:9.4.1211'

// Build Test Data
compile "org.grails.plugins:build-test-data:3.3.1"

// Audit Logging
compile "org.grails.plugins:audit-logging:3.0.1"

// Quartz
compile "org.grails.plugins:quartz:2.0.13"

// Phone Numbers
compile 'ca.redtoad:grails-phonenumbers:0.11'

// Rest Client
compile 'org.grails:grails-datastore-rest-client'

// Jasper
compile "org.grails.plugins:jasper:2.1.0.RC1"

//excel import
compile 'org.grails.plugins:excel-import:3.0.2'

//Quartz monitor
compile ('org.grails.plugins:quartz-monitor:1.3'){
exclude group: 'org.grails.plugins', module: 'asset-pipeline'
}

compile group: 'com.google.code.gson', name: 'gson', version: '2.8.5'

compile "org.grails.plugins:views-json:1.2.8"

//ajout des dependances de keycloak
compile "org.keycloak:keycloak-spring-security-adapter:3.0.0.Final"
runtime "org.jboss.logging:jboss-logging:3.3.0.Final"

//File upload
compile 'commons-fileupload:commons-fileupload:1.4'

// Include external jars
compile fileTree(dir: 'libs', include: '*.jar')

// pour les tests
testCompile "org.grails:grails-test-mixins:3.3.0"
testCompile "org.grails:grails-gorm-testing-support:1.1.5"
testCompile "org.grails:grails-web-testing-support:1.1.5"
}

bootRun {
jvmArgs('-Dspring.output.ansi.enabled=always')
addResources = true
}

integrationTest {
testLogging {
exceptionFormat = 'full'
events 'failed', 'standardOut', 'standardError'
}
beforeTest { descriptor ->
logger.quiet " -- $descriptor"
}
}

assets {
minifyJs = true
minifyCss = true
packagePlugin = true
includes = ["metronic_v4_7_1_admin_3_rounded/*"]
}

cobertura {
coverageFormats = ['xml', 'html']
}

test.finalizedBy(project.tasks.cobertura)

最佳答案

我能够找到为什么无法上传任何文件的原因:在我的Resources.groovy文件中,我有:

import org.springframework.web.filter.RequestContextFilter

beans{
...
requestContextFilter(RequestContextFilter)
}

此行阻止我上传所有文件。

关于file - grails 3.3.9从输入获取文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54652069/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com