2015/12/18

EF framework LIKE Hibernate SaveOrUpdate()


 from:
http://stackoverflow.com/questions/7552433/what-is-the-equivalent-for-hibenate-saveorupdate-in-entity-framework
果然是stackflow,馬上找到

There is no equivalent. You really have to write it like:
using (DataContext context = new DataContext())
{
    context.Task.Attach(task);
    if (task.ID == 0)
    {
         context.ObjectStateManager.ChangeObjectState(task, System.Data.EntityState.Added);
    }
    else
    {
         context.ObjectStateManager.ChangeObjectState(task, System.Data.EntityState.Modified);
    }

    context.SaveChanges();
 }

2015/12/9

jsp頁面的頭部空白行


From:http://www.111cn.net/jsp/Java/55593.htm
           http://kirby86a.pixnet.net/blog/post/111632383-%E8%A8%AD%E5%AE%9Atomcat-7%EF%BC%8C%E5%8E%BB%E9%99%A4%E7%B7%A8%E8%AD%AF%E5%BE%8C%E7%9A%84jsp%E4%B8%8A%E6%96%B9%E7%94%A2%E7%94%9F%E5%A4%A7%E9%87%8F%E7%9A%84
原因是網頁上方宣告,
例如:
<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
若是在宣告使用其他taglib或引入其他方法,那麼空白行就會更多,

方案一:
<%out.clear();%>
缺點:
後面的部分都要緊跟向前縮進不推,
主要是自己也還是暫用一行空白不推薦

方案二:
<%@ page trimDirectiveWhitespaces="true" %>

方案三: in web.xml
<jsp-config>
  <jsp-property-group>
    <url-pattern>*.jsp</url-pattern>
    <trim-directive-whitespaces>true</trim-directive-whitespaces>
  </jsp-property-group>
</jsp-config>


方案四:
如果Tomcat是 Tomcat5.x版本,即JSP2.0和Servlet2.4的規範
web.xml:
<servlet>
         <servlet-name>jsp</servlet-name>
         <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
        <init-param>
             <param-name>trimSpaces</param-name>
             <param-value>true</param-value>
         </init-param>
         <load-on-startup>3</load-on-startup>
     </servlet>

windows 無法拖動文件

原因:未知 症狀:windows點任何文件,都無法拖動到其他地方  解決方式: 來源: https://answers.microsoft.com/en-us/windows/forum/all/drag-and-drop-stopped-working/b73e4938-ca2...