java ee 基础常识

来源:互联网 发布:java学了有什么用 编辑:程序博客网 时间:2024/05/05 20:35

1、java web project目录结构


2、wtpwebapps与webapps区别

    这个仅仅是不同路径而已,没有特别的不同。因为在tomcat server at localhost下面Server Locations选择的是第二个导致

3、web.xml

     如果不配置web.xml,web工程将跑不起来(亲经);

     web.xml的加载顺序是: context-param -> listener -> filter -> servlet, 详细可以参考这篇文章: http://www.blogjava.net/fancydeepin/archive/2013/03/30/java-ee_web-xml.html

     在 web.xml 中 servelt元素与 servlet-mapping 是一一对应的servlet主要是为了指明具体的实现类,servlet-mapping 主要用来定义url,用来调用servlet 中指明的具体实现类,例如:

<servlet>    <servlet-name>MhpServlet</servlet-name>    <servlet-class>com.ztkj.app.base.servlet.MhpServlet</servlet-class>  </servlet>  <servlet-mapping>    <servlet-name>MhpServlet</servlet-name>    <url-pattern>/servlet/*</url-pattern>  </servlet-mapping>

    <init-param> </init-param>,这里面主要是servlet范围内的参数,只能在servlet的init()方法中看到,例如:

<init-param><param-name>contextConfigLocation</param-name><param-value>classpath:appServlet.xml</param-value></init-param>


4、http协议

    http是一个超文本协议,而非传输技术,作用于应用层,它依赖于传输层的 tcp/ip 协议进行两端的信息交互。因此,客户端与服务端之间的通讯实际上是通过下层的socket工具类进行tcp/ip交互


5、jsp 基本元素讲解

    jsp 中 pageEncoding 是 jsp 编译成 servlet 时使用的编码

    jsp 中 charset 是服务器发送给客户端时的内容编码


6、什么是 DTD

    DTD 全称叫 Document Type Definition - 文档类型定义。它有两个作用:一个规范你编写合理的代码,二是让浏览器正确的显示代码。

    它往往写在文档的第一行,这样它才能告诉浏览器你用的什么标记语言,如果你代码编写正确,加上用的合适的DTD,浏览器会根据 W3C 的标准正确显示你的代码。在网页中我们常常可看到:

<!DOCTYPE html  PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html>  <head>    头部信息  </head>  <body>    可视内容  </body></html>  

7、xmlns

<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"xmlns:p="http://www.springframework.org/schema/p"    xmlns:aop="http://www.springframework.org/schema/aop"    xmlns:tx="http://www.springframework.org/schema/tx"xmlns:context="http://www.springframework.org/schema/context"xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsdhttp://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/tx          http://www.springframework.org/schema/tx/spring-tx.xsd          http://www.springframework.org/schema/aop          http://www.springframework.org/schema/aop/spring-aop.xsdhttp://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
xmlns 表示命名空间,下面的就表示默认的命名空间
xmlns="http://www.springframework.org/schema/beans"
除了默认的命名空间之外,这个就必须要用 mvc 方式来写,比如 schemaLocation 就是他的一个属性,所以写成 xsi:schemaLocation,实际等同于<import namespace="XXX" schemaLocation=""/>

xmlns:mvc="http://www.springframework.org/schema/mvc"

xsi:schemaLocation="http://www.springframework.org/schema/mvc 

8、什么是 proxool 

    Proxool 是一种 java 数据库连接池技术。这个连接池提供监控的功能,便于发现链接泄露的情况。

    Proxool 提供了一个接口,用来读取 xml 和 propertity 格式的配置信息。


9、.project 与 .classpath

    有时候我们在导入一个工程的时候,可能是工程下面没有这两个文件导致,从别的工程拷贝这两个文件导入之后可能解决问题。

    .project 只需要修改 <name></name> 项目名称即可。 .classpath 文件一般不需要更改。

    那这两个文件的到底有什么作用呢?

    .project 是项目文件,项目的结构信息都存放在其中,例:lib 的位置, src 的位置, classes 的位置。

    .classpath 定义了你这个项目在编译时所使用的 $CLASSPATH


10、http 与 https 区别

    https 全称叫 Secure Hypertext Transfer Protocol (安全超文本协议)。它是基于 http 开发,用于在客户计算机和服务器之间交换信息。它使用安全套接层(SSL)进行信息交换。

    他们使用的是不同的链接方式,端口也不一样,前者是80,后者是443。

    https 比 http 更加安全,它是由 SSL + HTTP 协议构建的可进行加密传输、身份认证的网络协议。

    http 信息是明文传输,链接也很简单,是无状态的

    https 需要到 ca 申请证书,一般免费证书很少, 需要交费

    

11、JPA 与 hibernate 关系

    JPA 通过 jdk5.0 注解 或 xml 描述对象关系表的映射关系,并将运行期的实体对象持久化到数据库中。

    JPA 与 hibernate 的关系,可以简单的理解为 JPA 是标准接口,hibernate 是实现。hibernate 主要通过三个组件来实现,hibernate-annotation、hibernate-entitymanager 及 hibernate-core。

    这篇文章把 jpa 描述的比较清晰:http://www.thinksaas.cn/group/topic/350408/

            

12、什么是连接池

    连接池允许多个客户端使用缓存起来的连接对象,这些连接是可重复使用的。打开/关闭 数据库连接的开销很大,连接池技术允许我们在连接池里维护连接对象。

    我们可配置最大、最小连接数、最大空闲连接数。服务启动时最小连接数被创建,并添加到连接池中。    


13、什么是token

   session 的状态是存在服务端, 客户端只是存 session id;而 token 的状态是存在客户端的。

    

14、什么是 SSL

    SSL 全称(Secure Sockets Layer 安全套接层),及其继承者传输层安全(Transport Layer Security)是为网络通信提供安全及数据完整性的一种安全协议。TLS与SSL在传输层对网络连接进行加密。


15、






0 0