当前位置: 首页 > news >正文

做网站要会哪些软件太原要做网站的公司

做网站要会哪些软件,太原要做网站的公司,越秀微网站建设,福州网页模板建站本文主要包括以下内容 注解 注解 1、注解就是为了说明java中的某一个部分的作用(Type) 2、注解都可以用于哪个部门是Target注解起的作用 3、注解可以标注在ElementType枚举类所指定的位置上 4、 Documented //该注解是否出现在帮助文档中 Retention(Retenti…本文主要包括以下内容 注解 注解 1、注解就是为了说明java中的某一个部分的作用(Type) 2、注解都可以用于哪个部门是Target注解起的作用 3、注解可以标注在ElementType枚举类所指定的位置上 4、 Documented //该注解是否出现在帮助文档中 Retention(RetentionPolicy.RUNTIME) //该注解在java,class和运行时都起作用 Target(ElementType.ANNOTATION_TYPE)//该注解只能用于注解上 public interface Target { ElementType[] value(); } 5、用来解析注解的类成为注解解析器 自定义注解实例 类注解 package cn.itcast.annotation.sh;import java.lang.annotation.Documented; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target;Documented Retention(RetentionPolicy.RUNTIME) Target(ElementType.TYPE) public interface Description {String value(); }方法注解 package cn.itcast.annotation.sh;import java.lang.annotation.Documented; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target;Documented Retention(RetentionPolicy.RUNTIME) Target(ElementType.METHOD) public interface MethodDesc {String name(); } 注解的使用 package cn.itcast.annotation.sh;Description(whuhan university) public class ITCAST_SH {MethodDesc(namewhu)public void java(){System.out.println(this is java);} } 注解解析 package cn.itcast.annotation.sh;import java.lang.reflect.Method;import org.junit.Test;public class AnnotationParse {Testpublic void testParse(){Class class1 ITCAST_SH.class;if(class1.isAnnotationPresent(Description.class)){Description description (Description)class1.getAnnotation(Description.class);if(description.value().contains(whuhan)){System.out.println(学费减半);}}Method[] methods class1.getMethods();for(Method method:methods){if(method.isAnnotationPresent(MethodDesc.class)){MethodDesc methodDesc (MethodDesc)method.getAnnotation(MethodDesc.class);if(methodDesc.name().contains(whu)){System.out.println(折上折);}}}} } Resource注解的使用(依赖注入) 1、在spring的配置文件中导入命名空间 http://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context-2.5.xsd 2、引入注解解析器 context:annotation-config/context:annotation-config 3、在spring的配置文件中把bean引入进来 4、在一个类的属性上加 Resource(namestudent_annotation)private Student student;从该注解本身Target({TYPE, FIELD, METHOD})Retention(RUNTIME)public interface Resource {String name() default ;} 1、该注解可以用于属性上或者方法上但是一般用户属性上 2、该注解有一个属性name,默认值为”” 5、分析整个过程 1、当启动spring容器的时候spring容器加载了配置文件 2、在spring配置文件中只要遇到bean的配置就会为该bean创建对象 3、在纳入spring容器的范围内查找所有的bean,看哪些bean的属性或者方法上加有Resource 4、找到Resource注解以后判断该注解name的属性是否为”“(name没有写) 如果没有写name属性则会让属性的名称的值和spring中ID的值做匹配如果匹配成功则赋值 如果匹配不成功则会按照类型进行匹配如果匹配不成功则报错 如果有name属性则会按照name属性的值和spring的bean中ID进行匹配匹配成功则赋值不成功则报错 实例 package cn.itcast.spring.annotation.di;public class Student {public void show(){System.out.println(student);} } Person.java package cn.itcast.spring.annotation.di;import java.util.List; import java.util.Map; import java.util.Properties; import java.util.Set;import javax.annotation.Resource;import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier;public class Person {private Long pid;private String pname;Resource(namestudent_annotation) // Autowired // Qualifier(student)private Student student;private Set sets;private List lists;private Map map;private Properties properties;public void showStudent(){this.student.show();} }XML文件 ?xml version1.0 encodingUTF-8? beans xmlnshttp://www.springframework.org/schema/beansxmlns:contexthttp://www.springframework.org/schema/contextxmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:schemaLocationhttp://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-2.5.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context-2.5.xsd!-- 注解解析器--context:annotation-config/context:annotation-configbean idperson_annotation classcn.itcast.spring.annotation.di.Person/beanbean idstudent_annotation classcn.itcast.spring.annotation.di.Student/bean /beans 类扫描的注解Component使用 1、在spring的配置文件中导入命名空间 http://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context-2.5.xsd 2、加入下面的语句 context:component-scan base-packagecn.itcast.annotation.scan/context:component-scan 1、 该注解解析器包含了两个功能依赖注入和类扫描 2、在base-package包及子包下查找所有的类 3、如果一个类上加了Component注解就会进行如下的法则 如果其value属性的值为 Componentpublic class Person {}bean idperson class..Person如果其value属性的值不为Component(p)public class Person {}bean idp class..Person 4、按照Resource的法则再次进行操作 实例 package cn.itcast.annotation.scan;import org.springframework.stereotype.Component;Component(b) //bean idb class..Student public class Student {public void show(){System.out.println(student);} } person.java package cn.itcast.annotation.scan;import javax.annotation.Resource;import org.springframework.stereotype.Component;Component(a) //bean ida class..Person public class Person {Resource(nameb)private Student student;public void showStudent(){this.student.show();} } XML文件的配置 ?xml version1.0 encodingUTF-8? beans xmlnshttp://www.springframework.org/schema/beansxmlns:contexthttp://www.springframework.org/schema/contextxmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:schemaLocationhttp://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-2.5.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context-2.5.xsd!-- 类扫描的注解解析器component 指的就是一个类base-package 在该包及子包中进行扫描--context:component-scan base-packagecn.itcast.annotation.scan/context:component-scan /beans 新特性 Spring 2.5引入了更多典型化注解(stereotype annotations) Component、Service和 Controller。 Component是所有受Spring管理组件的通用形式 而Repository、Service和 Controller则是Component的细化 用来表示更具体的用例(例如分别对应了持久化层、服务层和表现层)。也就是说 你能用Component来注解你的组件类 但如果用Repository、Service或Controller来注解它们你的类也许能更好地被工具处理或与切面进行关联。 例如这些典型化注解可以成为理想的切入点目标。当然在Spring Framework以后的版本中Repository、Service和 Controller也许还能携带更多语义。如此一来如果你正在考虑服务层中是该用 Component还是Service 那Service显然是更好的选择。同样的就像前面说的那样 Repository已经能在持久化层中进行异常转换时被作为标记使用了。 示例 PersonAction(控制层) package cn.itcast.annotation.mvc;import javax.annotation.Resource;import org.springframework.stereotype.Controller;Controller(personAction) public class PersonAction {Resource(namepersonService)private PersonService personService;public void savePerson(){this.personService.savePerson();} } PersonServiceImpl(service层) package cn.itcast.annotation.mvc;import javax.annotation.Resource;import org.springframework.stereotype.Service;Service(personService) public class PersonServiceImpl implements PersonService{Resource(namepersonDao)private PersonDao personDao;Overridepublic void savePerson() {// TODO Auto-generated method stubthis.personDao.savePerson();}} PersonDaoImpl(dao层) package cn.itcast.annotation.mvc;import org.springframework.stereotype.Repository;Repository(personDao) public class PersonDaoImpl implements PersonDao{Overridepublic void savePerson() {// TODO Auto-generated method stubSystem.out.println(save person dao);}} xml与注解 1、xml书写麻烦但是效率高 2、注解书写简单但是效率低 完成
http://www.huolong8.cn/news/216227/

相关文章:

  • 做360手机网站永州网站开发
  • 东风地区网站建设价格低国内知名的网站设计公司
  • 怎么做p2p网站培训机构怎么找
  • 国外做机械设计任务的网站戴尔官方网站建设启示
  • 网站建设成本控制软件定制官网
  • 联合易网做网站工程建设施工企业质量管理规范
  • 北京网站建设 一流自己做pc网站建设
  • 网站百度收录重庆建设网站哪家专业
  • 网站建设网站设计哪家专业用dw制作个介绍家乡网站
  • 创建自己的网站哈尔滨建设工程招标网
  • 网站建设 服务质量保证设计大型网站建设
  • 专业做互联网招聘的网站utc wordpress
  • 网站建设方案如何讲解怎么进wordpress后台
  • 网站的公共头部怎么做网站制作公司 沈阳
  • 什么网站是用php做的浙江信息港查询三类证书
  • 移动端网站开发项目报告教学平台
  • asp网站怎么做山大优秀网站建设2018年度
  • 马云1688网站在濮阳如何做定制网络开发流程
  • 目前做定制产品的网站宁波网站关键词推广
  • 美容 网站源码网站域名到期怎么办
  • 购物网站模板免费下载营销推广计划书
  • 网页设计网站有哪些佛山网站提升排名
  • 做酒吧设计的网站苏州市亿韵商务信息有限公司
  • 网站建设空间多大wordpress角色名
  • 班级响应式网站html格式网站建设与管理的发展
  • 一个网站项目的价格表网站建设案例平台
  • 如何建立一个自己的网站?网站的内容管理
  • 电子商务网站设计的三大原则深圳官方网站制作
  • 做网站 做app好建站系统的选用分析
  • 怎么开网站手机网站开源