建 一 个 项 目
file→new→dynamic web project→ //这里若是找不到就other→winzards手动输入搜索
project name //输入你的包名
use default location //保存包的路径,你的包就放在这里面,勾选
target runtime:apache tomcat v9.0
dynamic web module version:4.0
configuration:dafault configuration for apache tomcat v9.0
next→
将WebContent修改为WebRoot
generate web.xml deployment descriptor //勾选,之后会在WebRoot下生成xml文件
//这里若是没有勾选,默认不会产生web.xml文件,解决办法:选中项目,右键→Java ee tools→generate deployment destriptor stub,完成后即可生成web.xml
finish→
有三个类,.java .xml .html
.java类
java resources→src
点击java resources,右键new→class,
package //输入你的包名
name //输入你的类名
superclass→browse→choose a type:输入https...→找到httpservlet→选中点OK
finish→
.xml类
webroot→web-int→web.xml
.html类
webroot→右键new→html file→
file name //输入类名
finish→
补充一下:
.java类
src右键→ new→ servlet→
Java package:输入包名
class name:输入类名
superclass:javax.servlet.http.HttpServlet
next→
initialization parameters:→点击右边的add→
name:value
value:123456
OK→
next→
取消勾选inherited abstract methods,勾选下面doget,dopost
finish→
.jsp是在webroot包下面建立的
webroot右键→new→other→搜索jsp,选择jsp file→file name→finish
关于.java页面编码
- 点击空白处右键,source→override/implement methods...→在httpservlet下勾选doget和dopost→OK
- 删除super.doGet(req, resp);和super.doPost(req, resp);
- 新手把request, response单词补全
完结撒花~
包package,类class