我在Grails中使用插件上传器以方便上传。当我输入" \"反斜杠会导致错误。
<uploadr:add name="Uplaoder" path="\tmp\uploadr\myFirstUploadr" direction="up" maxVisible="5" >
错误位于页面底部。
如果我将路径值更改为&#34; / example&#34;或类似的东西,这个错误不是原因,即它不是在页面加载时添加文件。
我正在使用spring security,所以我认为这可能有效但不确定如何或者是什么?
非常感谢任何帮助。
我收到以下错误
URI
/xx/datafile/index
Class
org.codehaus.groovy.control.MultipleCompilationErrorsException
Message
startup failed: General error during parsing: Did not find four digit hex character code. line: 136 col:178 groovyjarjarantlr.TokenStreamIOException: Did not find four digit hex character code. line: 136 col:178 at org.codehaus.groovy.antlr.parser.GroovyLexer.nextToken(GroovyLexer.java:730) at org.codehaus.groovy.antlr.parser.GroovyLexer$1.nextToken(GroovyLexer.java:259) at groovyjarjarantlr.TokenBuffer.fill(TokenBuffer.java:69) at groovyjarjarantlr.TokenBuffer.LA(TokenBuffer.java:80) at groovyjarjarantlr.LLkParser.LA(LLkParser.java:52) at
org.codehaus.groovy.antlr.parser.GroovyRecognizer.balancedTokens(GroovyRecognizer.java:3421) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.balancedBrackets(GroovyRecognizer.java:14339) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.balancedTokens(GroovyRecognizer.java:3422) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.balancedBrackets(GroovyRecognizer.java:14328) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.balancedTokens(GroovyRecognizer.java:3422) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.balancedBrackets(GroovyRecognizer.java:14317) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.balancedTokens(GroovyRecognizer.java:3422) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.balancedBrackets(GroovyRecognizer.java:14339) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.balancedTokens(GroovyRecognizer.java:3422) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.balancedBrackets(GroovyRecognizer.java:14317) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.balancedTokens(GroovyRecognizer.java:3422) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.balancedBrackets(GroovyRecognizer.java:14339) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.balancedTokens(GroovyRecognizer.java:3422) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.balancedBrackets(GroovyRecognizer.java:14317) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.balancedTokens(GroovyRecognizer.java:3422) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.balancedBrackets(GroovyRecognizer.java:14339) at
org.codehaus.groovy.antlr.parser.GroovyRecognizer.argumentLabelStart(GroovyRecognizer.java:14219) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.argument(GroovyRecognizer.java:13989) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.argList(GroovyRecognizer.java:7006) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.methodCallArgs(GroovyRecognizer.java:12087) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.pathElement(GroovyRecognizer.java:11666) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.pathExpression(GroovyRecognizer.java:11796) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.postfixExpression(GroovyRecognizer.java:13509) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.unaryExpressionNotPlusMinus(GroovyRecognizer.java:13478) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.powerExpressionNotPlusMinus(GroovyRecognizer.java:13182) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.multiplicativeExpression(GroovyRecognizer.java:13114) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.additiveExpression(GroovyRecognizer.java:12784) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.shiftExpression(GroovyRecognizer.java:9983) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.relationalExpression(GroovyRecognizer.java:12689) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.equalityExpression(GroovyRecognizer.java:12613) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.regexExpression(GroovyRecognizer.java:12561) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.andExpression(GroovyRecognizer.java:12529) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.exclusiveOrExpression(GroovyRecognizer.java:12497) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.inclusiveOrExpression(GroovyRecognizer.java:12465) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.logicalAndExpression(GroovyRecognizer.java:12433) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.logicalOrExpression(GroovyRecognizer.java:12401) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.conditionalExpression(GroovyRecognizer.java:4956) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.assignmentExpression(GroovyRecognizer.java:8184) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.expression(GroovyRecognizer.java:10160) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.expressionStatementNoCheck(GroovyRecognizer.java:8511) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.expressionStatement(GroovyRecognizer.java:9057) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.statement(GroovyRecognizer.java:1278) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.blockBody(GroovyRecognizer.java:1587) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.openBlock(GroovyRecognizer.java:8473) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.variableDefinitions(GroovyRecognizer.java:2453) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.declaration(GroovyRecognizer.java:2229) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.classField(GroovyRecognizer.java:5992) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.classBlock(GroovyRecognizer.java:5286) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.classDefinition(GroovyRecognizer.java:1965) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.typeDefinitionInternal(GroovyRecognizer.java:1829) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.statement(GroovyRecognizer.java:1309) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.compilationUnit(GroovyRecognizer.java:760) at org.codehaus.groovy.antlr.AntlrParserPlugin.transformCSTIntoAST(AntlrParserPlugin.java:131) at org.codehaus.groovy.antlr.AntlrParserPlugin.parseCST(AntlrParserPlugin.java:108) at org.codehaus.groovy.control.SourceUnit.parse(SourceUnit.java:236) at org.codehaus.groovy.control.CompilationUnit$1.call(CompilationUnit.java:164) at
org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:923) at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:585) at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:561) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:538) at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:286) at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:259) at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:245) at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:203) at org.codehaus.groovy.grails.web.pages.GroovyPagesTemplateEngine.compileGroovyPage(GroovyPagesTemplateEngine.java:608) at org.codehaus.groovy.grails.web.pages.GroovyPagesTemplateEngine.buildPageMetaInfo(GroovyPagesTemplateEngine.java:560) at org.codehaus.groovy.grails.web.pages.GroovyPagesTemplateEngine.buildPageMetaInfo(GroovyPagesTemplateEngine.java:459) at org.codehaus.groovy.grails.web.pages.GroovyPagesTemplateEngine$1$1.updateValue(GroovyPagesTemplateEngine.java:280) at org.codehaus.groovy.grails.web.pages.GroovyPagesTemplateEngine$1$1.updateValue(GroovyPagesTemplateEngine.java:265) at grails.util.CacheEntry.getValue(CacheEntry.java:141) at grails.util.CacheEntry.getValue(CacheEntry.java:81) at org.codehaus.groovy.grails.web.pages.GroovyPagesTemplateEngine.createTemplate(GroovyPagesTemplateEngine.java:262) at org.codehaus.groovy.grails.web.pages.GroovyPagesTemplateEngine.createTemplate(GroovyPagesTemplateEngine.java:252) at org.codehaus.groovy.grails.web.pages.GroovyPagesTemplateEngine.createTemplate(GroovyPagesTemplateEngine.java:374) at org.codehaus.groovy.grails.web.servlet.view.GroovyPageView.initTemplate(GroovyPageView.java:170) at org.codehaus.groovy.grails.web.servlet.view.GroovyPageView.afterPropertiesSet(GroovyPageView.java:159) at org.codehaus.groovy.grails.web.servlet.view.GroovyPageViewResolver.createGroovyPageView(GroovyPageViewResolver.java:187) at org.codehaus.groovy.grails.web.servlet.view.GroovyPageViewResolver.createGrailsView(GroovyPageViewResolver.java:170) at org.codehaus.groovy.grails.web.servlet.view.GroovyPageViewResolver.loadView(GroovyPageViewResolver.java:96) at org.springframework.web.servlet.view.AbstractCachingViewResolver.createView(AbstractCachingViewResolver.java:244) at org.springframework.web.servlet.view.UrlBasedViewResolver.createView(UrlBasedViewResolver.java:402) at org.springframework.web.servlet.view.AbstractCachingViewResolver.resolveViewName(AbstractCachingViewResolver.java:146) at org.codehaus.groovy.grails.web.servlet.view.GroovyPageViewResolver.resolveViewName(GroovyPageViewResolver.java:85) at org.codehaus.groovy.grails.web.servlet.view.GrailsLayoutViewResolver.resolveViewName(GrailsLayoutViewResolver.java:50) at org.springframework.web.servlet.DispatcherServlet.resolveViewName(DispatcherServlet.java:1260) at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1201) at org.codehaus.groovy.grails.web.servlet.GrailsDispatcherServlet.doDispatch(GrailsDispatcherServlet.java:387) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:870) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:852) at javax.servlet.http.HttpServlet.service(HttpServlet.java:620) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837) at javax.servlet.http.HttpServlet.service(HttpServlet.java:727) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:198) at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:344) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:261) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:101) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:101) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:101) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:748) at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:486) at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:411) at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:338) at org.codehaus.groovy.grails.web.mapping.UrlMappingUtils.forwardRequestForUrlMappingInfo(UrlMappingUtils.java:178) at org.codehaus.groovy.grails.web.mapping.UrlMappingUtils.forwardRequestForUrlMappingInfo(UrlMappingUtils.java:144) at org.codehaus.groovy.grails.web.mapping.UrlMappingUtils.forwardRequestForUrlMappingInfo(UrlMappingUtils.java:135) at org.codehaus.groovy.grails.web.mapping.filter.UrlMappingsFilter.doFilterInternal(UrlMappingsFilter.java:216) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at grails.plugin.springsecurity.web.filter.GrailsAnonymousAuthenticationFilter.doFilter(GrailsAnonymousAuthenticationFilter.java:53) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter.doFilter(RememberMeAuthenticationFilter.java:146) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:154) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:199) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at grails.plugin.springsecurity.web.authentication.logout.MutableLogoutFilter.doFilter(MutableLogoutFilter.java:62) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at grails.plugin.springsecurity.web.SecurityRequestHolderFilter.doFilter(SecurityRequestHolderFilter.java:59) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192) at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:344) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:261) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.codehaus.groovy.grails.web.servlet.mvc.GrailsWebRequestFilter.doFilterInternal(GrailsWebRequestFilter.java:69) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.codehaus.groovy.grails.web.filters.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:67) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:344) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:261) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1040) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:313) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) 1 error
答案 0 :(得分:0)
我找到了解决方案,导致错误的原因是反斜杠是一个转义字符,我正在开发Windows。
我的解决方案
在config.groovy中添加
中的以下行uploadr.defaultUploadPath="pathwhereyouwanttostore/folder"
然后在你的gsp中
<%@page expressionCodec="raw" %>
<%
def downloads = grailsApplication.config.uploadr.defaultUploadPath
def path1 = new File("${downloads}/folderName")
%>
请注意,上面的内容位于页面顶部,并且只是暂时的,因为这样做是不好的做法,path1应该由您的控制器传入。
这是uplaodr然后
<div class="col-md-6">
<uploadr:add name="Upload" path="${path1}" maxSize="52428800" />
</div>