入口函数代码:
@At("/upload")
@Ok("raw:html")
public Object upload(HttpServletRequest request){
System.out.println(request.getContextPath());
System.out.println(request.getServletPath());
System.out.println(request.getHeaderNames());
System.out.println("id para "+request.getParameter("id"));
System.out.println("id attr "+request.getAttribute("id"));
// File file = (File) request.getAttribute("file");
// System.out.println(null==file);
// System.out.println(file.getName());
// System.out.println(file.getAbsolutePath());
StringBuffer str = new StringBuffer();
// str.append("<h1>file.getName() "+file.getName()+"</h1>");
// str.append("<h1>file.getAbsolutePath() "+file.getAbsolutePath()+"</h1>");
return str.toString();
}
index.html页面:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<form enctype="multipart/form-data" action="/upload" method="post">
id:<input type="text" name="id" /><p></p>
nanme:<input type="text" name="name" /><p></p>
file:<input type="file" name="file"/><p></p>
<button type="submit" value="提交">提交2</button>
</form>
</body>
</html>
运行结果:
D:\tomcat-7.0.90\bin\catalina.bat run
[2018-10-28 11:25:01,943] Artifact nutzdemo:war exploded: Waiting for server connection to start artifact deployment...
Using CATALINA_BASE: "C:\Users\admin\.IntelliJIdea2018.2\system\tomcat\Unnamed_NutzDemo"
Using CATALINA_HOME: "D:\tomcat-7.0.90"
Using CATALINA_TMPDIR: "C:\Users\admin\.IntelliJIdea2018.2\system\tomcat\Unnamed_NutzDemo\temp"
Using JRE_HOME: "D:\jdk1.8.0"
Using CLASSPATH: "D:\tomcat-7.0.90\bin\bootstrap.jar;D:\tomcat-7.0.90\bin\tomcat-juli.jar"
十月 28, 2018 11:25:03 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Server version: Apache Tomcat/7.0.90
十月 28, 2018 11:25:03 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Server built: Jul 2 2018 17:05:37 UTC
十月 28, 2018 11:25:03 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Server number: 7.0.90.0
十月 28, 2018 11:25:03 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: OS Name: Windows 10
十月 28, 2018 11:25:03 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: OS Version: 10.0
十月 28, 2018 11:25:03 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Architecture: amd64
十月 28, 2018 11:25:03 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Java Home: D:\jdk1.8.0\jre
十月 28, 2018 11:25:03 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: JVM Version: 1.8.0_181-b13
十月 28, 2018 11:25:03 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: JVM Vendor: Oracle Corporation
十月 28, 2018 11:25:03 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: CATALINA_BASE: C:\Users\admin\.IntelliJIdea2018.2\system\tomcat\Unnamed_NutzDemo
十月 28, 2018 11:25:03 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: CATALINA_HOME: D:\tomcat-7.0.90
十月 28, 2018 11:25:03 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Djava.util.logging.config.file=C:\Users\admin\.IntelliJIdea2018.2\system\tomcat\Unnamed_NutzDemo\conf\logging.properties
十月 28, 2018 11:25:03 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
十月 28, 2018 11:25:03 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dcom.sun.management.jmxremote=
十月 28, 2018 11:25:03 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dcom.sun.management.jmxremote.port=1011
十月 28, 2018 11:25:03 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dcom.sun.management.jmxremote.ssl=false
十月 28, 2018 11:25:03 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dcom.sun.management.jmxremote.authenticate=false
十月 28, 2018 11:25:03 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Djava.rmi.server.hostname=127.0.0.1
十月 28, 2018 11:25:03 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
十月 28, 2018 11:25:03 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dignore.endorsed.dirs=
十月 28, 2018 11:25:03 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dcatalina.base=C:\Users\admin\.IntelliJIdea2018.2\system\tomcat\Unnamed_NutzDemo
十月 28, 2018 11:25:03 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dcatalina.home=D:\tomcat-7.0.90
十月 28, 2018 11:25:03 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Djava.io.tmpdir=C:\Users\admin\.IntelliJIdea2018.2\system\tomcat\Unnamed_NutzDemo\temp
十月 28, 2018 11:25:03 下午 org.apache.catalina.core.AprLifecycleListener lifecycleEvent
信息: Loaded APR based Apache Tomcat Native library 1.2.17 using APR version 1.6.3.
十月 28, 2018 11:25:03 下午 org.apache.catalina.core.AprLifecycleListener lifecycleEvent
信息: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
十月 28, 2018 11:25:04 下午 org.apache.catalina.core.AprLifecycleListener initializeSSL
信息: OpenSSL successfully initialized (OpenSSL 1.0.2o 27 Mar 2018)
十月 28, 2018 11:25:04 下午 org.apache.coyote.AbstractProtocol init
信息: Initializing ProtocolHandler ["http-apr-80"]
十月 28, 2018 11:25:04 下午 org.apache.coyote.AbstractProtocol init
信息: Initializing ProtocolHandler ["ajp-apr-8009"]
十月 28, 2018 11:25:04 下午 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 1358 ms
十月 28, 2018 11:25:04 下午 org.apache.catalina.core.StandardService startInternal
信息: Starting service Catalina
十月 28, 2018 11:25:04 下午 org.apache.catalina.core.StandardEngine startInternal
信息: Starting Servlet Engine: Apache Tomcat/7.0.90
十月 28, 2018 11:25:04 下午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["http-apr-80"]
十月 28, 2018 11:25:04 下午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["ajp-apr-8009"]
十月 28, 2018 11:25:04 下午 org.apache.catalina.startup.Catalina start
信息: Server startup in 72 ms
Connected to server
[2018-10-28 11:25:04,567] Artifact nutzdemo:war exploded: Artifact is being deployed, please wait...
十月 28, 2018 11:25:05 下午 org.apache.catalina.startup.TldConfig execute
信息: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
18-10-28 23:25:05.416 INFO [RMI TCP Connection(3)-127.0.0.1] Select SystemLog as Nutz.Log implement
18-10-28 23:25:05.522 INFO [RMI TCP Connection(3)-127.0.0.1] NutFilter[nutz] starting ...
18-10-28 23:25:05.535 DEBUG [RMI TCP Connection(3)-127.0.0.1] Locations count=3 time use 3ms
18-10-28 23:25:05.574 DEBUG [RMI TCP Connection(3)-127.0.0.1] Locations count=9 time use 39ms
18-10-28 23:25:05.583 DEBUG [RMI TCP Connection(3)-127.0.0.1] Loading by class org.nutz.mvc.impl.NutLoading
18-10-28 23:25:05.586 INFO [RMI TCP Connection(3)-127.0.0.1] Nutz Version : 1.r.63.r3-20171220
18-10-28 23:25:05.586 INFO [RMI TCP Connection(3)-127.0.0.1] Nutz.Mvc[nutz] is initializing ...
18-10-28 23:25:05.586 DEBUG [RMI TCP Connection(3)-127.0.0.1] Web Container Information:
18-10-28 23:25:05.588 DEBUG [RMI TCP Connection(3)-127.0.0.1] - Default Charset : GBK
18-10-28 23:25:05.588 DEBUG [RMI TCP Connection(3)-127.0.0.1] - Current . path : D:\tomcat-7.0.90\bin\.
18-10-28 23:25:05.588 DEBUG [RMI TCP Connection(3)-127.0.0.1] - Java Version : 1.8.0_181
18-10-28 23:25:05.588 DEBUG [RMI TCP Connection(3)-127.0.0.1] - File separator : \
18-10-28 23:25:05.588 DEBUG [RMI TCP Connection(3)-127.0.0.1] - Timezone : Asia/Shanghai
18-10-28 23:25:05.588 DEBUG [RMI TCP Connection(3)-127.0.0.1] - OS : Windows 10 amd64
18-10-28 23:25:05.589 DEBUG [RMI TCP Connection(3)-127.0.0.1] - ServerInfo : Apache Tomcat/7.0.90
18-10-28 23:25:05.589 DEBUG [RMI TCP Connection(3)-127.0.0.1] - Servlet API : 3.0
18-10-28 23:25:05.589 DEBUG [RMI TCP Connection(3)-127.0.0.1] - ContextPath :
18-10-28 23:25:05.589 DEBUG [RMI TCP Connection(3)-127.0.0.1] - context.tempdir : C:\Users\admin\.IntelliJIdea2018.2\system\tomcat\Unnamed_NutzDemo\work\Catalina\localhost\_
18-10-28 23:25:05.589 DEBUG [RMI TCP Connection(3)-127.0.0.1] - MainModule : net.wendal.nutzbook.MainModule
18-10-28 23:25:05.590 DEBUG [RMI TCP Connection(3)-127.0.0.1] >> app.root = D:/CodeProject/nutzdemo/target/nutzdemo
18-10-28 23:25:05.657 DEBUG [RMI TCP Connection(3)-127.0.0.1] Using 95 castor for Castors
18-10-28 23:25:05.658 DEBUG [RMI TCP Connection(3)-127.0.0.1] @IocBy(type=org.nutz.mvc.ioc.provider.ComboIocProvider, args=["*js", "datasource.js", "*anno", "net.wendal.nutzbook"],init=[])
18-10-28 23:25:05.684 DEBUG [RMI TCP Connection(3)-127.0.0.1] Found 1 resource by src( datasource.js ) , regex( ^(.+[.])(js|json)$ )
18-10-28 23:25:05.685 DEBUG [RMI TCP Connection(3)-127.0.0.1] loading [datasource.js]
18-10-28 23:25:05.687 DEBUG [RMI TCP Connection(3)-127.0.0.1] Loaded 2 bean define from path=[datasource.js] --> [dataSource, dao]
18-10-28 23:25:05.691 INFO [RMI TCP Connection(3)-127.0.0.1] > scan 'net.wendal.nutzbook'
18-10-28 23:25:05.695 DEBUG [RMI TCP Connection(3)-127.0.0.1] Found 4 resource by src( net/wendal/nutzbook/ ) , regex( ^.+[.]class$ )
18-10-28 23:25:05.703 INFO [RMI TCP Connection(3)-127.0.0.1] > add 'userModule ' - net.wendal.nutzbook.controller.UserModule
18-10-28 23:25:05.712 INFO [RMI TCP Connection(3)-127.0.0.1] > add 'user ' - net.wendal.nutzbook.pojo.User
18-10-28 23:25:05.721 INFO [RMI TCP Connection(3)-127.0.0.1] > add 'userService ' - net.wendal.nutzbook.service.UserService
18-10-28 23:25:05.741 INFO [RMI TCP Connection(3)-127.0.0.1] ... NutIoc init complete
18-10-28 23:25:05.745 INFO [RMI TCP Connection(3)-127.0.0.1] Build URL mapping by org.nutz.mvc.impl.UrlMappingImpl ...
18-10-28 23:25:05.747 DEBUG [RMI TCP Connection(3)-127.0.0.1] @Views(DefaultViewMaker.class)
18-10-28 23:25:05.753 DEBUG [RMI TCP Connection(3)-127.0.0.1] @ChainBy(org.nutz.mvc.impl.NutActionChainMaker)
18-10-28 23:25:05.762 DEBUG [RMI TCP Connection(3)-127.0.0.1] module class location 'file:/D:/CodeProject/nutzdemo/target/nutzdemo/WEB-INF/classes/'
18-10-28 23:25:05.762 DEBUG [RMI TCP Connection(3)-127.0.0.1] > scan 'net.wendal.nutzbook'
18-10-28 23:25:05.765 DEBUG [RMI TCP Connection(3)-127.0.0.1] Found 4 resource by src( net/wendal/nutzbook/ ) , regex( ^.+[.]class$ )
18-10-28 23:25:05.766 DEBUG [RMI TCP Connection(3)-127.0.0.1] >> add 'net.wendal.nutzbook.controller.UserModule'
18-10-28 23:25:05.767 DEBUG [RMI TCP Connection(3)-127.0.0.1] Use org.nutz.mvc.impl.NutEntryDeterminer as EntryMethodDeterminer
18-10-28 23:25:05.782 INFO [RMI TCP Connection(3)-127.0.0.1] Optional processor class not found, disabled : org.nutz.integration.shiro.NutShiroProcessor
18-10-28 23:25:05.791 INFO [RMI TCP Connection(3)-127.0.0.1] Optional processor class not found, disabled : org.nutz.plugins.validation.ValidationProcessor
18-10-28 23:25:05.808 DEBUG [RMI TCP Connection(3)-127.0.0.1] '/upload' >> (UserModule.java:61).upload : Object | @Ok(raw:html) @Fail(null ) | by 0 Filters | (I:UTF-8/O:UTF-8)
18-10-28 23:25:05.810 DEBUG [RMI TCP Connection(3)-127.0.0.1] '/selectAll' >> (UserModule.java:39).selectAll : List | @Ok(json ) @Fail(null ) | by 0 Filters | (I:UTF-8/O:UTF-8)
18-10-28 23:25:05.820 DEBUG [RMI TCP Connection(3)-127.0.0.1] '/test' >> (UserModule.java:54).Test : Object | @Ok(raw:html) @Fail(null ) | by 0 Filters | (I:UTF-8/O:UTF-8)
18-10-28 23:25:05.821 DEBUG [RMI TCP Connection(3)-127.0.0.1] '/selectById/?' >> (UserModule.java:46).selectById : Object | @Ok(json ) @Fail(null ) | by 0 Filters | (I:UTF-8/O:UTF-8)
18-10-28 23:25:05.821 INFO [RMI TCP Connection(3)-127.0.0.1] Found 4 module methods
18-10-28 23:25:05.821 DEBUG [RMI TCP Connection(3)-127.0.0.1] @Localization not define
18-10-28 23:25:05.823 INFO [RMI TCP Connection(3)-127.0.0.1] Nutz.Mvc[nutz] is up in 232ms
[2018-10-28 11:25:05,848] Artifact nutzdemo:war exploded: Artifact is deployed successfully
[2018-10-28 11:25:05,848] Artifact nutzdemo:war exploded: Deploy took 1,281 milliseconds
18-10-28 23:25:06.233 DEBUG [http-apr-80-exec-2] Search mapping for [GET] path=/index : NOT Action match
18-10-28 23:25:06.238 DEBUG [http-apr-80-exec-4] Search mapping for [GET] path=/index : NOT Action match
18-10-28 23:25:06.692 DEBUG [http-apr-80-exec-6] Search mapping for [GET] path=/index : NOT Action match
18-10-28 23:25:12.999 DEBUG [http-apr-80-exec-8] Search mapping for [GET] path=/index : NOT Action match
十月 28, 2018 11:25:14 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory D:\tomcat-7.0.90\webapps\manager
十月 28, 2018 11:25:14 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deployment of web application directory D:\tomcat-7.0.90\webapps\manager has finished in 115 ms
18-10-28 23:25:15.320 DEBUG [http-apr-80-exec-10] Found mapping for [POST] path=/upload : UserModule.upload(UserModule.java:61)
18-10-28 23:25:15.321 DEBUG [http-apr-80-exec-10] Get 'userModule'<class net.wendal.nutzbook.controller.UserModule>
18-10-28 23:25:15.323 DEBUG [http-apr-80-exec-10] Load AopConfigure for anno=org.nutz.ioc.aop.Aop by type=org.nutz.ioc.aop.config.impl.AnnotationAopConfigration
18-10-28 23:25:15.323 DEBUG [http-apr-80-exec-10] >> Load definition name=userModule
18-10-28 23:25:15.324 DEBUG [http-apr-80-exec-10] Found IocObject(userModule) in AnnotationIocLoader(packages=[net.wendal.nutzbook])
18-10-28 23:25:15.324 DEBUG [http-apr-80-exec-10] >> Make...'userModule'<class net.wendal.nutzbook.controller.UserModule>
18-10-28 23:25:15.325 DEBUG [http-apr-80-exec-10] Save object 'userModule' to [app]
18-10-28 23:25:15.327 DEBUG [http-apr-80-exec-10] Load class net.wendal.nutzbook.controller.UserModule without AOP
18-10-28 23:25:15.334 DEBUG [http-apr-80-exec-10] Get 'userService'<class net.wendal.nutzbook.service.UserService>
18-10-28 23:25:15.334 DEBUG [http-apr-80-exec-10] >> Load definition name=userService
18-10-28 23:25:15.334 DEBUG [http-apr-80-exec-10] Found IocObject(userService) in AnnotationIocLoader(packages=[net.wendal.nutzbook])
18-10-28 23:25:15.334 DEBUG [http-apr-80-exec-10] >> Make...'userService'<class net.wendal.nutzbook.service.UserService>
18-10-28 23:25:15.334 DEBUG [http-apr-80-exec-10] Save object 'userService' to [app]
18-10-28 23:25:15.335 DEBUG [http-apr-80-exec-10] Load class net.wendal.nutzbook.service.UserService without AOP
18-10-28 23:25:15.337 DEBUG [http-apr-80-exec-10] name=dao2 not found, search for type=org.nutz.dao.Dao
18-10-28 23:25:15.337 DEBUG [http-apr-80-exec-10] Found IocObject(dataSource) in JsonLoader(paths=[datasource.js])
18-10-28 23:25:15.338 DEBUG [http-apr-80-exec-10] Found IocObject(dao) in JsonLoader(paths=[datasource.js])
18-10-28 23:25:15.338 DEBUG [http-apr-80-exec-10] Get 'dao'<interface org.nutz.dao.Dao>
18-10-28 23:25:15.338 DEBUG [http-apr-80-exec-10] >> Load definition name=dao
18-10-28 23:25:15.338 DEBUG [http-apr-80-exec-10] >> Make...'dao'<interface org.nutz.dao.Dao>
18-10-28 23:25:15.338 DEBUG [http-apr-80-exec-10] Save object 'dao' to [app]
18-10-28 23:25:15.339 DEBUG [http-apr-80-exec-10] Get 'dataSource'<>
18-10-28 23:25:15.339 DEBUG [http-apr-80-exec-10] >> Load definition name=dataSource
18-10-28 23:25:15.339 DEBUG [http-apr-80-exec-10] >> Make...'dataSource'<>
18-10-28 23:25:15.340 DEBUG [http-apr-80-exec-10] Save object 'dataSource' to [app]
18-10-28 23:25:15.365 DEBUG [http-apr-80-exec-10] Load class com.alibaba.druid.pool.DruidDataSource without AOP
18-10-28 23:25:15.518 DEBUG [http-apr-80-exec-10] Load class org.nutz.dao.impl.NutDao without AOP
18-10-28 23:25:15.518 DEBUG [http-apr-80-exec-10] Get 'dataSource'<>
18-10-28 23:25:15.661 DEBUG [http-apr-80-exec-10] Jdbcs init complete
18-10-28 23:25:15.661 INFO [http-apr-80-exec-10] Get Connection from DataSource for JdbcExpert, if you lock at here, check your database server and configure
十月 28, 2018 11:25:15 下午 com.alibaba.druid.pool.DruidDataSource info
信息: {dataSource-1} inited
18-10-28 23:25:15.888 DEBUG [http-apr-80-exec-10] select expert : org.nutz.dao.impl.jdbc.mysql.MysqlJdbcExpert
18-10-28 23:25:15.898 DEBUG [http-apr-80-exec-10] JDBC Driver --> mysql-connector-java-5.1.6 ( Revision: ${svn.Revision} )
18-10-28 23:25:15.898 DEBUG [http-apr-80-exec-10] JDBC Name --> MySQL-AB JDBC Driver
18-10-28 23:25:15.898 DEBUG [http-apr-80-exec-10] JDBC URL --> jdbc:mysql://localhost:3306/nutzbook
18-10-28 23:25:15.903 DEBUG [http-apr-80-exec-10] Mysql : character_set_client=utf8
18-10-28 23:25:15.903 DEBUG [http-apr-80-exec-10] Mysql : character_set_connection=utf8
18-10-28 23:25:15.903 DEBUG [http-apr-80-exec-10] Mysql : character_set_database=utf8
18-10-28 23:25:15.903 DEBUG [http-apr-80-exec-10] Mysql : character_set_filesystem=binary
18-10-28 23:25:15.904 DEBUG [http-apr-80-exec-10] Mysql : character_set_results=
18-10-28 23:25:15.904 DEBUG [http-apr-80-exec-10] Mysql : character_set_server=utf8
18-10-28 23:25:15.904 DEBUG [http-apr-80-exec-10] Mysql : character_set_system=utf8
18-10-28 23:25:15.904 DEBUG [http-apr-80-exec-10] Mysql : character_sets_dir=D:\DataBase\MySQL Server 5.5.61\share\charsets\
18-10-28 23:25:15.905 DEBUG [http-apr-80-exec-10] Mysql : binlog_format=STATEMENT
18-10-28 23:25:15.905 DEBUG [http-apr-80-exec-10] Mysql : database=nutzbook
18-10-28 23:25:15.906 DEBUG [http-apr-80-exec-10] Mysql : user=root@localhost
18-10-28 23:25:15.920 DEBUG [http-apr-80-exec-10] Database info --> MYSQL:[MySQL - 5.5.61]
/upload
org.apache.tomcat.util.http.NamesEnumerator@28af7675
id para null
id attr null