日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

s2sh整合笔记

發布時間:2024/1/18 编程问答 42 豆豆
生活随笔 收集整理的這篇文章主要介紹了 s2sh整合笔记 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1. 接口

1.1 book_searchByType.action

首頁 查書

1.2 addFieldError(“bookListNullError”);

2. 筆記

2.1 時間問題

Mysql 與 java 的時間類型 MySql的時間類型有 Java中與之對應的時間類型 date java.sql.Date Datetime java.sql.Timestamp Timestamp java.sql.Timestamp Time java.sql.Time Year java.sql.Date 轉換相互轉換: Date date = new Date();//獲得系統時間. String nowTime = new SimpleDateFormat(“yyyy-MM-dd HH:mm:ss”).format(date); Timestamp goodsC_date = Timestamp.valueOf(nowTime);//把時間轉換 java.util.Date 是java.sql.Date的父類datetime 8bytes xxxx-xx-xx xx:xx:xx 1000-01-01 00:00:00到9999-12-31 23:59:59 timestamp 4bytes xxxx-xx-xx xx:xx:xx 1970-01-01 00:00:01到2038 date 3bytes xxxx-xx-xx 1000-01-01到9999-12-31 year 1bytes xxxx 1901到2155 time 3bytes xx:xx:xx -838:59:59到838:59:59(為了滿足時間的加減運算)

2.2 在spring中使用struts

  • 不需要在spring配置文件中注入service,就是bean
  • spring會根據當前id的名字來注入service
  • struts配置文件中action的class還是用class
  • 在action中service要提宮set方法。
  • 配置文件修改之后要重新加載。
  • 2.3 struts.xml文件一直報錯,找不到spring創建的bean的action的class路徑。因為沒有正確的配置spring的配置文件

    2.4 struts2 怎樣取得循環的索引

    <s:iterator value="list" id="user" status="L"><s:property value="#L.index+1"/>、<s:property value="#user.name"/><br> </s:iterator>#L.index,即為list的索引 其中L是個IteratorStatus對象 List<User> User對象含有name和password屬性。當然你也可以寫成: <s:iterator value="list" id="user" status="L"><s:property value="${L.index+1}"/>、<s:property value="${user.name}"/><br> </s:iterator>

    2.5 button發送異步請求,antion 不會有請求。。

    要判斷返回結果,就要用如下。 還可以通過瀏覽器開發者模式

    <%--發送郵箱驗證碼js--%><script>function down() {alert("確定要發送給:" + document.getElementById("email").value + "\n" + "由于某些原因可能會被存放到垃圾箱");var param = "?email=" + document.getElementById("email").value;var url = "${pageContext.request.contextPath}/sendEmailRegister" + param;var request = new XMLHttpRequest();request.open("POST", url);request.send();request.onreadystatechange = function () {//若響應完成且請求成功if (request.readyState === 4 && request.status === 200) {// alert("郵箱未注冊");document.getElementById("fat-btn").click();}else {alert("郵箱已注冊");return false;}}}</script>

    2.6 href 中的url最好不要加action后綴

    2.7 編寫到一半時發現只有bookid才可以唯一確定一個書

    2.8 a標簽是怎么傳參的?是url?id=XXX這樣的形式嗎?

    在action中有HttpServletRequest
    request對象,struts里的action用ServletActionContext.getRequest()獲得這個request,然后可以用request.getParameter(“id”)來獲得相應參數值。-
    不同框架可能獲取額值不一樣?;径际沁@種request.getParameter(“參數的name”);

    2.9 對cookie加密 base64

    loginEmailnull12345@qq.com loginPwdnull12345 JSESSIONIDnullE90C45289476F9BD4F7755573EAACE46 Idea-4aeff5b9null9e9d78a0-4462-4fd4-9736-62584fb31e67 Idea-5129d8f2null9e9d78a0-4462-4fd4-9736-62584fb31e67

    2.10Hibernate 一對多查詢對set的排序

    Hibernate可以進行一對多的關聯查詢,例如:查詢了試卷題目,可以自動獲取試卷題目的選項對象。

    但是關聯出來的集合對象是無序的,那么在顯示的時候就會有問題,經過百度發現可以對Set進行設置排序。

    order-by屬性用于設置數據庫對集合元素的排序,該屬性的值為指定表的指定字段(一個或幾個)加上asc或者desc關鍵字,這種排序是數據庫執行SQL查詢時進行的排序,而不是直接在內存中排序。

    在Set標簽中可以增加order-by屬性進行字段的排序設置.

    格式:[N向表數據庫字段名稱 ASC/DESC]

    例如:order-by=”F_NAME ASC”

    2.11 在form表單里,如果對input加入disabled="disabled"或disabled="true"等屬性,form表單提交的時候,就不會傳值到后臺。

    原因:在HTML頁面的某元素加入了disable的屬性,那么這個元素只是單單的去給用戶去顯示,當表單提交時,這個元素不會提交給后臺去處理.所以當元素加入了disabled屬性,后臺是無法得到這個屬性的值.

    解決方法:再寫一個隱藏屬性,一個用于顯示,一個用于傳值。

    2.12 使form 表單只提交一次

    <body onload="form.submit();"><form name="form" action="url" method="post"><input type="text" id="name" value="zhang"/></form></body>

    https://blog.csdn.net/jiankunking/article/details/17992435

    2.13 Map session = ActionContext.getContext().getSession();

    兩種session一樣

    2.14 關于Cookie報錯An invalid character [44] was present in the Cookie value

    查資料:其實很簡單,你看報錯信息An invalid character [44] was present in the Cookie value,ascii為44的字符是“,”,說明cookie不支持“,”,你可以換成“#”,可能與toncat版本有關,但是為了這個去換tomcat有點得不償失

    2.15 下載文件臨時文件

  • 詳解struts.multipart.saveDir的臨時文件路徑
  • 不設置struts.multipart.saveDir
    這種情況下,臨時文件就放在tomcat安裝目錄下的"work\Catalina\localhost\項目名稱"目錄下。

    2.16 “Error:(1, 1) java: 非法字符: ‘\ufeff’”錯誤解決辦法

    原來這是因為Windows記事本在修改UTF-8文件時自作聰明地在文件開頭添加BOM導致的,所以才會導致IDEA不能正確讀取.java文件從而程序出錯。

    解決辦法
    在編輯器IDEA中將文件編碼更改為UTF-16,再改回UTF-8即可,其實就相當于刷新了一下文件編碼。

    2.17路徑問題

    在struts2 action中讀取properties文件內容和在普通的Java類中的路徑是不一樣的
    1. ServletActionContext.getServletContext().getClassLoader() .getResourceAsStream("com/bookshop/email/email.properties");

    2.18 spring注入,但action中service為null

    https://bbs.csdn.net/topics/390361076
    樓主你錯了,action中private TestService testService;這個是不對的。改成這樣就可以了 private TestServiceImpl testService;你注入的是service實現類而不是接口,所以在action中應該用實現類而不是接口

    2.19 java.lang.IllegalStateException: Cannot create a session after the response has been committed

    我覺得這個問題的主要原因就在重定向response提交后,后面springmvc繼續重定向了頁面,或者多session有某些操作,所以會報這種錯誤。

    2.20 Hibernate saveOrUpdate失效以及補救方案

    2.21 使用模型驅動失敗原因。

  • 實現ModelDriven
  • users u = new users();
  • 實現方法
  • 2.22 登錄時的請求

    http://localhost:8080/second_hand_bookshop_war_exploded/user_login.action?loginEmail=&loginPwd=&remember=on

    2.23 ServletActionContext和ActionContext有著一些重復的功能,該如何去抉擇?

    遵循的原則是:ActionContext能夠實現我們的功能,最好就不要使用ServletActionContext,讓Action盡量不要直接去訪問Servlet的相關對象。

    2.24 saveOrUpdate為什么會直接創建一個新的記錄而不是更新

    我之前獲取前端的user和數據庫的user不一樣

    2.25 Hibernate加載數據失敗failed to lazily initialize a collection of role

    http://www.itzhai.com/hibernate-load-data-failed-failed-to-lazily-initialize-a-collection-of-role.html

    2.26 filderError

    ActionContext.getContext().getSession().put(“emailExistError”, “該郵箱不存在或未注冊”);
    ActionContext.getContext().getSession().put(“emailSendError”, “發送郵件失敗”);

    2.27 問題SLF4J

    SLF4J: Failed to load class “org.slf4j.impl.StaticLoggerBinder”. SLF4J:
    Defaulting to no-operation (NOP) logger implementation SLF4J: See
    http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
    MLog initialization issue: slf4j found no binding or threatened to use
    its (dangerously silent) NOPLogger. We consider the slf4j library not
    found.

    SLF4J:即簡單日志門面(Simple Logging Facade for Java),不是具體的日志解決方案,它只服務于各種各樣的日志系統。按照官方的說法,SLF4J是一個用于日志系統的簡單Facade,允許最終用戶在部署其應用時使用其所希望的日志系統。

    在使用SLF4J的時候,不需要在代碼中或配置文件中指定你打算使用那個具體的日志系統,SLF4J提供了統一的記錄日志的接口,只要按照其提供的方法記錄即可,最終日志的格式、記錄級別、輸出方式等通過具體日志系統的配置來實現,因此可以在應用中靈活切換日志系統。

    2.28 再用映射創建實體類時。自動修改了c3p0的配置

    <prop key="hibernate.connection.url">jdbc:mysql://localhost:3306/second-hand bookshop</prop> <prop key="hibernate.connection.driver_class">com.mysql.jdbc.Driver</prop> <prop key="connection.username">root</prop> <prop key="connection.password">111111</prop>

    2.29 完美解決 ERROR 1064 (42000): You have an error in your SQL syntax … near …

    https://blog.csdn.net/jdjdndhj/article/details/70242174

    2.30 check the manual that corresponds to your MySQL server version for the right syntax to use near ‘constraint UK_i4xw3txse101x4hp8erct9j46’

    表的seller的索引有問題
    去掉 unique

    2.31 iterator 奇偶數不同和判斷

    <table><s:iterator value="{'北京','上海','廣州'}" var="name" status="st"><tr><s:if test="#st.Even"><td style="background: red"><s:property value="#st.index"/><s:property value="name"/></td></s:if><s:else><td style="background: green"><s:property value="#st.index"/><s:property value="name"/></td></s:else></tr></s:iterator> </table>

    2.32 chain使用

    <result name="offShelfBooksSuccess" type="chain">seller_checkSeller</result><result name="onShelfBooksSuccess" type="chain">seller_checkSeller</result>

    總結

    以上是生活随笔為你收集整理的s2sh整合笔记的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。