Struts2的配置問題和hibernate的配置問題
阿新 • • 發佈:2018-11-28
1、Struts2的web.xml的配置問題
這個問題是因為你的web.xml過濾器配置的問題
如果你的過濾器配置的是*.action的話,就只能通過後臺程式碼訪問jsp頁面
例: <filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>*.action</url-pattern> </filter-mapping>
因為如果不通過action而直接訪問jsp頁面的話,Struts2標籤在解析的時候會獲取當前執行緒ThreadLocal中的Dispatcher。而Dispatcher是在Struts過濾器中預設的。
程式碼如下: Java程式碼 public static ValueStack getStack(PageContext pageContext) { HttpServletRequest req = (HttpServletRequest) pageContext.getRequest(); ValueStack stack = (ValueStack) req.getAttribute(ServletActionContext.STRUTS_VALUESTACK_KEY); if (stack == null) { HttpServletResponse res = (HttpServletResponse) pageContext.getResponse(); Dispatcher du = Dispatcher.getInstance(); if (du == null) { throw new ConfigurationException("The Struts dispatcher cannot be found. This is usually caused by "+ "using Struts tags without the associated filter. Struts tags are only usable when the request "+ "has passed through its servlet filter, which initializes the Struts dispatcher needed for this tag."); }
2、hibernate sql語句表名後面多了一個;號
解決辦法是檢查你的實體類配置檔案
table屬性表名後面的;號刪除就可以了