在官网构建好后,自己写了一个Module,代码如下:
package io.nutz.book.module;
@At("/book")
@IocBean
public class BookModule {
@Inject
Dao dao;
@At("/doAdd")
@POST
public void add() {
dao.create(Book.class, true);
Book b = new Book();
b.setId(1);
b.setBookname("java开发实践");
b.setPrice(20);
dao.insert(b);
}
}
访问“http://127.0.0.1:8080/book/doAdd”报404,控制台如下:
[DEBUG] 11:12:48.956 org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:712) - Processing socket [org.apache.tomcat.util.net.NioChannel@3cef6e5e:java.nio.channels.SocketChannel[connected local=/127.0.0.1:8080 remote=/127.0.0.1:54543]] with status [OPEN_READ]
[DEBUG] 11:12:48.957 org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:724) - Found processor [null] for socket [org.apache.tomcat.util.net.NioChannel@3cef6e5e:java.nio.channels.SocketChannel[connected local=/127.0.0.1:8080 remote=/127.0.0.1:54543]]
[DEBUG] 11:12:48.958 org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:789) - Popped processor [null] from cache
[DEBUG] 11:12:49.030 org.apache.coyote.AbstractProtocol$ConnectionHandler.register(AbstractProtocol.java:1029) - Register Tomcat:type=RequestProcessor,worker="http-nio-8080",name=HttpRequest1
[DEBUG] 11:12:49.033 org.apache.coyote.http11.Http11InputBuffer.parseRequestLine(Http11InputBuffer.java:402) - Received [GET /book/doAdd HTTP/1.1
Host: 127.0.0.1:8080
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:68.0) Gecko/20100101 Firefox/68.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
Accept-Encoding: gzip, deflate
Connection: keep-alive
Cookie: sid=66n8lskp6egc1o9b0cva3kfg0o
Upgrade-Insecure-Requests: 1
]
[DEBUG] 11:12:49.072 org.nutz.mvc.impl.ActionInvoker.getActionChain(ActionInvoker.java:87) - Path=[/book/doAdd] available methods[POST] but request [GET], using the wrong http method?
[DEBUG] 11:12:49.072 org.nutz.mvc.impl.UrlMappingImpl.get(UrlMappingImpl.java:110) - Search mapping for [GET] path=/book/doAdd : NOT Action match
[DEBUG] 11:12:49.098 org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:74) - Socket: [org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper@63d812a2:org.apache.tomcat.util.net.NioChannel@3cef6e5e:java.nio.channels.SocketChannel[connected local=/127.0.0.1:8080 remote=/127.0.0.1:54543]], Status in: [OPEN_READ], State out: [OPEN]
[DEBUG] 11:12:49.098 org.apache.coyote.AbstractProtocol$ConnectionHandler.release(AbstractProtocol.java:996) - Pushed Processor [org.apache.coyote.http11.Http11Processor@625a3e80]
请问各位大神们,这是怎么回事,刚刚接触nutz,求大佬帮忙不胜感激