603719(603719中报)

603719(603719中报)

霍林河到乌兰浩特的收费站怎么绕过去

除了几个仅有的都绕不过去的,路上离收费站不远可以看见有下坡路就是了,现在越来越严了 前旗处有一个,另外要注意那里的路七扭八歪容易走差,我曾经走差过了收费站问交警才发现,最好不要天黑走

Spring中事物注解问题

? @controller? @service? @autowired? @requestmapping? @requestparam? @modelattribute? @cacheable? @cacheflush? @resource? @postconstruct? @predestroy? @repository? @component (不推荐使用)? @scope? @sessionattributes? @initbinder? @required? @qualifier@controller? 例如@controllerpublic class softcreatecontroller extends simplebasecontroller {}? 或者@controller(“softcreatecontroller”)? 说明@controller 负责注册一个bean 到spring 上下文中,bean 的id 默认为类名称开头字母小写@service? 例如@servicepublic class softcreateserviceimpl implements isoftcreateservice {}? 或者@service(“softcreateserviceimpl”)? 说明@service 负责注册一个bean 到spring 上下文中,bean 的id 默认为类名称开头字母小写@autowired? 例如@autowiredprivate isoftpmservice softpmservice;? 或者@autowired(required=false)private isoftpmservice softpmservice = new softpmserviceimpl();? 说明@autowired 根据bean 类型从spring 上线文中进行查找,注册类型必须唯一,否则报异常。与@resource 的区别在于,@resource 允许通过bean 名称或bean 类型两种方式进行查找@autowired(required=false) 表示,如果spring 上下文中没有找到该类型的bean 时, 才会使用new softpmserviceimpl();@autowired 标注作用于 map 类型时,如果 map 的 key 为 string 类型,则 spring 会将容器中所有类型符合 map 的 value 对应的类型的 bean 增加进来,用 bean 的 id 或 name 作为 map 的 key。@autowired 还有一个作用就是,如果将其标注在 beanfactory 类型、applicationcontext 类型、resourceloader 类型、applicationeventpublisher 类型、messagesource 类型上,那么 spring 会自动注入这些实现类的实例,不需要额外的操作。@requestmapping? 类@controller @requestmapping(“/bbtforum.do”)public class bbtforumcontroller {@requestmapping(params = “method=listboardtopic”)public string listboardtopic(int topicid,user user) {}} ? 方法@requestmapping(“/softpg/downsoftpg.do”)@requestmapping(value=”/softpg/ajaxloadsoftid.do”,method = post)@requestmapping(value = “/osu/product/detail.do”, params = { “modify=false” }, method =post) ? 说明@requestmapping 可以声明到类或方法上? 参数绑定说明如果我们使用以下的 url 请求:?method=listboardtopic&topicid=1&userid=10&username=tomtopicid url 参数将绑定到 topicid 入参上,而 userid 和 username url 参数将绑定到 user 对象的 userid 和 username 属性中。和 url 请求中不允许没有 topicid 参数不同,虽然 user 的 userid 属性的类型是基本数据类型,但如果 url 中不存在 userid 参数,spring 也不会报错,此时 user.userid 值为 0 。如果 user 对象拥有一个 dept.deptid 的级联属性,那么它将和 dept.deptid url 参数绑定。@requestparam? 参数绑定说明@requestparam(“id”)?method=listboardtopic&id=1&userid=10&username=tomlistboardtopic(@requestparam(“id”)int topicid,user user) 中的 topicid 绑定到 id 这个 url 参数, 那么可以通过对入参使用 @requestparam 注解来达到目的@requestparam(required=false):参数不是必须的,默认为true@requestparam(value=”id”,required=false)请求处理方法入参的可选类型? java 基本数据类型和 string默认情况下将按名称匹配的方式绑定到 url 参数上,可以通过 @requestparam 注解改变默认的绑定规则? request/response/session 既可以是 servlet api 的也可以是 portlet api 对应的对象,spring 会将它们绑定到servlet 和 portlet 容器的相应对象上? org.springframework.web.context.request.webrequest 内部包含了 request 对象? java.util.locale绑定到 request 对应的 locale 对象上? java.io.inputstream/java.io.reader可以借此访问 request 的内容? java.io.outputstream / java.io.writer可以借此操作 response 的内容? 任何标注了 @requestparam 注解的入参被标注 @requestparam 注解的入参将绑定到特定的 request 参数上。? java.util.map / org.springframework.ui.modelmap它绑定 spring mvc 框架中每个请求所创建的潜在的模型对象,它们可以被 web 视图对象访问(如 jsp )? 命令/ 表单对象(注:一般称绑定使用 http get 发送的 url 参数的对象为命令对象,而称绑定使用http post 发送的 url 参数的对象为表单对象)它们的属性将以名称匹配的规则绑定到 url 参数上,同时完成类型的转换。而类型转换的规则可以通过 @initbinder 注解或通过 handleradapter 的配置进行调 整? org.springframework.validation.errors / org.springframework.validation.bindingresult为属性列表中的命令/ 表单对象的校验结果,注意检验结果参数必须紧跟在命令/ 表单对象的后面? org.springframework.web.bind.support.sessionstatus 可以通过该类型 status 对象显式结束表单的处理,这相当于触发 session 清除其中的通过@sessionattributes 定义的属性请求处理方法返回值的可选类型? void此时逻辑视图名由请求处理方法对应的 url 确定,如以下的方法:@requestmapping(“/welcome.do”)public void welcomehandler() {}对应的逻辑视图名为 “ welcome ” ? string此时逻辑视图名为返回的字符,如以下的方法:@requestmapping(method = requestmethod.get)public string setupform(@requestparam(“ownerid”) int ownerid, modelmap model) {owner owner = this.clinic.loadowner(ownerid);model.addattribute(owner);return “ownerform”;}对应的逻辑视图名为 “ ownerform ” ? org.springframework.ui.modelmap和返回类型为 void 一样,逻辑视图名取决于对应请求的 url ,如下面的例子:@requestmapping(“/vets.do”)public modelmap vetshandler() {return new modelmap(this.clinic.getvets());}对应的逻辑视图名为 “ vets ” ,返回的 modelmap 将被作为请求对应的模型对象,可以在 jsp 视图页面中访问到。? modelandview当然还可以是传统的 modelandview 。@modelattribute? 作用域:request? 例如@requestmapping(“/base/usermanagecooper/init.do”)public string handleinit(@modelattribute(“querybean”) manageduser suser,model model,){? 或者@modelattribute(“coopmap”)// 将coopmap 返回到页 面public mapcoopmapitems(){} ? 说明 @modelattribute 声明在属性上,表示该属性的value 来源于model 里”querybean” ,并被保存到model 里@modelattribute 声明在方法上,表示该方法的返回值被保存到model 里 @cacheable 和@cacheflush ? @cacheable :声明一个方法的返回值应该被缓 存 例如:@cacheable(modelid = “testcaching”) ? @cacheflush :声明一个方法是清空缓存的触发器 例如:@cacheflush(modelid = “testcaching”) ? 说明 要配合缓存处理器使用,参考: @resource ? 例如 @resource private datasource datasource; // inject the bean named ‘datasource’ ? 或者 @resource(name=”datasource”) @resource(type=datasource.class) ? 说明 @resource 默认按bean 的name 进行查找,如果没有找到会按type 进行查找, 此时与@autowired 类 似 在没有为 @resource 注解显式指定 name 属性的前提下,如果将其标注在 beanfactory 类型、applicationcontext 类型、resourceloader 类型、applicationeventpublisher 类型、messagesource 类型上,那么 spring 会自动注入这些实现类的实例,不需要额外的操作。此时 name 属性不需要指定 ( 或者指定为””),否则注入失败; @postconstruct 和@predestroy ? @postconstruct 在方法上加上注解@postconstruct ,这个方法就会在bean 初始化之后被spring 容器执 行 (注:bean 初始化包括,实例化bean ,并装配bean 的属性(依赖注入))。 ? @predestroy 在方法上加上注解@predestroy ,这个方法就会在bean 被销毁前被spring 容器执行。 @repository ? 与@controller 、@service 类似,都是向spring 上下文中注册bean ,不在赘述。 @component (不推荐使用) ? @component @component 是所有受spring 管理组件的通用形式,spring 还提供了更加细化的注解形式: @repository 、@service 、@controller ,它们分别对应存储层bean ,业务层bean ,和展示层bean 。 目前版本(2.5 )中,这些注解与@component 的语义是一样的,完全通用, 在spring 以后的版本中可能会给它们追加更多的语义。 所以,我们推荐使用@repository 、@service 、@controller 来替代@component 。 @scope ? 例如 @scope(“session”) @repository() public class usersessionbean implementsserializable {} ? 说明 在使用xml 定义bean 时,可以通过bean 的scope 属性来定义一个bean 的作用范围, 同样可以通过@scope 注解来完成 @scope中可以指定如下值: singleton:定义bean的范围为每个spring容器一个实例(默认值) prototype:定义bean可以被多次实例化(使用一次就创建一次) request:定义bean的范围是http请求(springmvc中有效) session:定义bean的范围是http会话(springmvc中有效) global-session:定义bean的范围是全局http会话(portlet中有效) @sessionattributes ? 说明 spring 允许我们有选择地指定 modelmap 中的哪些属性需要转存到 session 中, 以便下一个请求属对应的 modelmap 的属性列表中还能访问到这些属性。 这一功能是通过类定义处标注 @sessionattributes 注解来实现的。 @sessionattributes 只能声明在类上,而不能声明在方法上。 ? 例如 @sessionattributes(“curruser”) // 将modelmap 中属性名为curruser 的属性 @sessionattributes({“attr1″,”attr2”}) @sessionattributes(types = user.class) @sessionattributes(types = {user.class,dept.class}) @sessionattributes(types = {user.class,dept.class},value={“attr1″,”attr2”}) @initbinder ? 说明 如果希望某个属性编辑器仅作用于特定的 controller , 可以在 controller 中定义一个标注 @initbinder 注解的方法, 可以在该方法中向 controller 了注册若干个属性编辑器 ? 例如 @initbinder public void initbinder(webdatabinder binder) { simpledateformat dateformat = new simpledateformat(“yyyy-mm-dd”); dateformat.setlenient(false); binder.registercustomeditor(date.class, new customdateeditor(dateformat, false)); } @required ? 例如 @required public setname(string name){} ? 说明 @ required 负责检查一个bean在初始化时其声明的 set方法是否被执行, 当某个被标注了 @required 的 setter 方法没有被调用,则 spring 在解析的时候会抛出异常,以提醒开发者对相应属性进行设置。 @required 注解只能标注在 setter 方法之上。因为依赖注入的本质是检查 setter 方法是否被调用了,而不是真的去检查属性是否赋值了以及赋了什么样的值。如果将该注解标注在非 setxxxx() 类型的方法则被忽略。 @qualifier ? 例如 @autowired @qualifier(“softservice”) private isoftpmservice softpmservice; ? 说明 使用@autowired 时,如果找到多个同一类型的bean,则会抛异常,此时可以使用 @qualifier(“beanname”),明确指定bean的名称进行注入,此时与 @resource指定name属性作用相同。 求采纳为满意回答。

本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 1553299181@qq.com 举报,一经查实,本站将立刻删除。
如若转载,请注明出处:https://www.lmux.cn/52.html