SpringMVC知识点汇总



1.${SESSION_USER_V2}

创新互联专注于湘桥企业网站建设,自适应网站建设,商城系统网站开发。湘桥网站建设公司,为湘桥等地区提供建站服务。全流程按需求定制制作,专业设计,全程项目跟踪,创新互联专业和态度为您提供的服务

        会从大到小查找作用域中的attribute
          PageContext                          PageScope
          servletRequest                       RequestScope
          httpSession                         SessionScope
          Application/servletContext        ApplicationScope   
          
          
2.${param.name}

实际上是相当于request.getParameter("name")方法


3.空连接

href="#"方法:

其实也是空连接的意思,但是点击之后会自动跳转到页面的最上面,因为用了这个方法就相当于点击了一个锚记,但是这个锚记又没写ID,所以就默认跳转到页面顶部。

href="javascript:void(0);"方法:
void是一个操作符,这个操作符指定要计算一个表达式但是不返回值。如果在void中写入0(void(0)),则什么也不执行,从而也就形成了一个空链接。

#与javascript:void(0)的区别:
所以,#与javascript:void(0)的区别也很明显,#方法会跳转到页面的顶部,并且在页面URL后面会出现#,而javascript:void(0)方法不会,所以如果是空连接的话,还是推荐javascript:void(0)。



4.添加删除样式

$(function(){
    $("#myArticle").click(function(){
        $("#allArticle").removeClass("current");
        $("#myArticle").addClass("current");//最好不要用Attr()和removeAttr(),因为css样式会继承
    })    
    $("#allArticle").click(function(){
        $("#myArticle").removeClass("current");
        $("#allArticle").addClass("current");//
    })    
    
})



5.SpringMVC获取session
直接在方法上使用 HttpSession即可注入

或者注入HttpServletRequest--->再获取Session


6.拦截器配置
applicationContext.xml
 
       
           
           
          
           
       

   

    
7. context root设置问题

比如我们的项目名称是myApp(即myApp文件夹下有WEB-INFO文件夹),发布在本机80端口,且context-root设置为myApp,
则访问默认欢迎页面时的url是:http://localhost:80/myApp。如果context-root设置成/,则url会变成:http://localhost:80/

1.在新建web项目时,仔细观察会有输入框提示输入context-root,如果希望url是后者的样子,则context-root框中只输入"/"即可,否则输入你想要的目录名称;

2.如果您使用eclipse开发,则在项目上右击,然后选择属性,再选择Web Project Settings,然后修改

context-root内容;若您使用myEclipse开发,则右击项目-->“Properties”-->“MyEclipse”-->“Web”,看到了吧“Context Root”选项卡里的“Web Context-root”,修改之;

8.修改eclipse虚拟机内存
-vmargs
-Dosgi.requiredJavaVersion=1.6
-Xms256m
-Xmx1024m  堆内存
-XX:PermSize=512M    非堆内存
-XX:MaxPermSize=1024M

9.Target runtime Apache Tomcat v6.0 is not defined.
项目文件夹下
.settings\org.eclipse.wst.common.project.facet.core.xml文件中


 
 
 
 
 
 
 

删除掉



10. Server Tomcat v7.0 Server at localhost was unable to start within 45 seconds. If the server requires more time, try increasing the timeout in the server editor.

SpringMVC知识点汇总

11. ibatis中sql语句中#与$的区别


1.#是把传入的数据当作字符串,如#user_id_list#传入的是1,2,则sql语句生成是这样,in ('1,2') ,当然不可以

2.$传入的数据直接生成在sql里,如#user_id_list#传入的是1,2,则sql语句生成是这样,in(1,2) 这就对了.

3.#方式能够很大程度防止sql注入

4.$方式无法方式sql注入

5.$方式一般用于传入数据库对象,例如传入表名



直观的说
#str# 出来的效果是  'str'
$str$ 出来的效果是  str


另外  ##只能用在特定的几个地方 $$可以用在任何地方  比如 order by $str$

你甚至可以直接写  $str$  把 order by 这个字串放在str里传进来


12. model.addAttribute(article)

默认key为article的类型


13.springmvc的controller默认是单例的

可以加上@Scope("prototype")变为多实例的

14.标签

操作被用于以"名-值"对的形式为其他标签提供附加信息。
它可以和,,一起使用。


例1:实现 includeaction.jsp中展示come.jsp页面,值由主页面传入。

includeaction.jsp代码



    
    Include


    <%double i = Math.random();%>
    //加载come.jsp
        " />//传递参数
    


在come.jsp代码



    
    come


  
  <%//获得includeAction.jsp传来的值:
    String str = request.getParameter("number");
    double n = Double.parseDouble(str);
   %>
    The value form includeAction is:
 <%=n%>


15. return false
取消元素的默认行为


16.Ibatis中SqlMapClientTemplate和SqlMapClient的区别
SqlMapClientTemplate是org.springframework.orm.ibatis下的
而SqlMapClient是ibatis的
SqlMapClientTemplate是SqlMapClient的封装类.
SqlMapClient中包含着session的管理.
SqlMapClientTemplate用于session的封装,以及异常的捕捉.
所以按照以上的推断来说.应该尽量使用SqlMapClientTemplate.
保证session以及Exception的正常以及统一.
参考文章:
http://blog.csdn.net/wxwzy738/article/details/16953609


17.there is no statement named xxx in this SqlMap
sqlmap文件定义了namespace属性,就需要这样写:(你的namespace).(定义的statement的id),如果把namespace属性漏了,就被报此异常


    

    
        select * from category where status != -1
    

     
     insert into category(name) values (#name#)
     
     
     
     update category set status=-1 where id=#id#
     
     
   
        mst_sp_pageshowex4 '$columns$ ','$table$','$where$','$orderBy$',$pageSize$,$pageNo$
    

    
        sp_pagecount '$table$','$where$'
    




18. ibatis upadte delete insert 返回作用的行数

com.dooioo.web.converter.DyMappingJacksonHttpMessageConverter

19.HTTP400\HTTP500

HTTP400    错误的请求
HTTP500   内部服务器错误!

404请求 404状态码是一种http状态码,其意思是: 所请求的页面不存在或已被删除!
通俗的讲就是当用户输入了错误的链接时,返回的页面。

20.@ModelAttribute Article article, BindingResult result
(BindingResult result必须紧跟在@ModelAttribute后面)

21 @ModelAttribute和@Valid区别

@ModelAttribute is used to map/bind a a method parameter or method return type to a named model attribute. See @ModelAttributes JavaDoc. This is a Spring annotation.

@Valid is an annotation that marks an object for JSR-303 bean validation. See @Valids JavaDoc. It is part of JavaEE 6, but I think Hibernate has an earlier implementation that most people use instead.

The advantage of using @ModelAttribute is that you can map a form's inputs to a bean. The advantage of @Valid is that you can utilize JSR-303 bean validation to ensure that the bean that is made is validated against some set of rules.

Yes you can use @ModelAttribute and @Valid together.

JSR 303 – Bean Validation 是一个数据验证的规范

22.sqlserve服务器密码登录

http://blog.csdn.net/jufeng9318/article/details/8203780



23.EL表达式加三元表达式

 
 

24. web.xml启动顺序
 1.context-param
 2.listener
 3.filter
 4.servlet
         


标题名称:SpringMVC知识点汇总
当前地址:http://lszwz.com/article/jghjpi.html

其他资讯

售后响应及时

7×24小时客服热线

数据备份

更安全、更高效、更稳定

价格公道精准

项目经理精准报价不弄虚作假

合作无风险

重合同讲信誉,无效全额退款