在这里设置主页,从上往下找,找到后显示,不会再往下找
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>01/hello.html</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
(1)在html里访问另一个html的3种方式 (uri三种写法)
<a href="http://10.10.21.148:8080/javaweb0529/01/hello.html">第一种方式访问01/hello.html</a> 绝对路径
<a href="/javaweb0529/01/hello.html">第二种方式访问01/hello.html</a> 工程名前加/
<a href="01/hello.html">第三种方式访问01/hello.html</a> 相对路径前不加/
ie浏览器里有缓冲记录,删除历史记录(工具internet选项)
ContextRoot:上下文路径,可以修改上下文路径,但是一般工程名和上下文路径一致
工程--右键--properties--myeclipse--web--ContextRoot修改上下文路径,但是一般先把服务器关了,再删除,防止删除不干净。
web资源:html jsp servlet
在浏览器地址栏里访问的web项目,http://10.10.21.148:8080/javaweb0529/01/hello.html,都不写WebRoot,因为项目部署到tomcat上时,只是把webroot下的文件全部拷到webapps下面的某个文件夹下面(可以自己起名)。如果有servlet的话,那先把servlet编译成字节码在Web-INF下的classes里面,lib下是jar包。
(2)创建一个helloservlet,在web.xml里配置,客户如何访问
创建servlet步骤:
(1)src---右键---new---other---web---Servlet----里面的写入包名和类名--下一步配置Servlet信息,路径和名称什么的
HttpServletRequest 请求servlet
HttpServletResponse 响应servlet
3种访问方式
<a href="http://10.10.21.148:8080/javaweb0530/helloservlet">第一种方式访问servlet</a><br>
<a href="/javaweb0530/helloservlet">第二种方式访问servlet</a><br>
<a href="helloservlet">第三种方式访问servlet</a><br>
<servlet>
<description>This is the description of my J2EE component</description>
<display-name>This is the display name of my J2EE component</display-name>
<servlet-name>hello</servlet-name>
<servlet-class>com.ttc.test.HelloServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>hello</servlet-name>
<url-pattern>/helloservlet</url-pattern> //访问路径
</servlet-mapping>
(3)Request , Response对象
请求方法有get post put
Http Method Request file Http version
GET /Servlet/javaweb0530.helloservlet Http/1.0
get方法没有请求主体
请求头
空行
请求主体
这些信息全部封装到HttpServletRequest接口里,底层解析不需要了解。通过HttpServletRequest来得到各种参数。响应类似。
<servlet-name>ReadRequestinfo</servlet-name>
<url-pattern>/servlet/ReadRequestinfo</url-pattern>
不能重名,唯一,以/开头,不然启动服务器会报错
(4)登录练习