Recently, ESET add my domain name to the black-list of their database. You can’t open my site and been warned my site is not safe if your PC is running the ESS or EAV. Why Eset block my site?The answer is obvious. That is reason that you come here. I promise that my site is pure, no virus, no spyware, no Trojan, no pop ads. You can test my word through intalling Kaspersky or other Antivirus Software. If you want open my site and take latest escalation ID & Activation Code, close your ESET software(disable antivirus and antispyware protection function temporarily) or by proxy or virtual machinor. You can also feed the RSS source http://feed.loserblog.cn.
Recently, ESET add my domain name to the black-list of their database. You can’t open my site and been warned my site is not safe if your PC is running the ESS or EAV. Why Eset block my site?The answer is obvious. That is reason that you come here. I promise that my site is pure, no virus, no spyware, no Trojan, no pop ads. You can test my word through intalling Kaspersky or other Antivirus Software. If you want open my site and take latest escalation ID & Activation Code, close your ESET software(disable antivirus and antispyware protection function temporarily) or by proxy or virtual machinor. You can also feed the RSS source http://feed.loserblog.cn.
Archive
IDEA commonly used shortcut
The most commonly used shortcut
1.Ctrl + E, can show the recent editorial in the paper list
2.Shift + Click can close the document
3.Ctrl + [or] you can skip to the end of the brackets at the beginning
4.Ctrl + Shift + Backspace can edit Jump to last place
5.Ctrl + F12, can display the current structure of the document
6.Ctrl + F7 can find the current element in the current document cited in, then press F3 can choose
7.Ctrl + N, can quickly open category
8.Ctrl + Shift + N, can quickly open the file
9.Alt + Q can see that the current method of statement
10.Ctrl + W can choose words and then sentences and then will then function
11.Alt + F1 can edit the elements are in various panel positioning
12.Ctrl + P, can display information parameters
13.Ctrl + Shift + Insert can choose the clipboard contents and insert
14.Alt + Insert can generate constructor / Getter / Setter, etc.
15.Ctrl + Alt + V variables could be introduced. For example, the SQL given in brackets into a variable
16.Ctrl + Alt + T can be wrapped in a code, for example, try / catch
17.Alt + Up and Alt + Down in the way of fast-moving
Below is not very useful
18. In some places by Alt + Enter can get some Intention Action, for example, "==" to "equals ()"
19.Ctrl + Shift + Alt + N can quickly open symbols
20.Ctrl + Shift + Space in many cases can give Smart Tips
21.Alt + F3 can quickly find
22.Ctrl + / and Ctrl + Shift + / code can Notes
23.Ctrl + Alt + B can Jump to abstract methods of achieving
24.Ctrl + O father can choose the method of rewriting category
25.Ctrl + Q can see JavaDoc
26.Ctrl + Alt + Space is the type of auto-complete
27. Quickly open / documents / symbols, you can use wildcards, can also use abbreviations
28.Live Templates! Ctrl + J
29.Ctrl + Shift + F7 to highlight the current element in the current document the use of
30.Ctrl + Alt + Up / Ctrl + Alt + Down search results can quickly Jump
31.Ctrl + Shift + J can integrate the two lines
32.Alt + F8 value is calculated variables
Use org.json to analytical and structural JSON
Use org.json to analytical and structural JSON in java
json many analytical tools, which org.json is relatively lightweight.
http://www.json.org/java/json.zip
org.json the use of analytical and tectonic processes:
import java.util.HashMap;
import java.util.Map;
import org.json.JSONException;
import org.json.JSONObject;
public class Test (
public static void main (String [] args) throws JSONException (
String json = "(\" name \ ": \" reiz \ ")";
JSONObject jsonObj = new JSONObject (json);
String name = jsonObj.getString ( "name");
jsonObj.put ( "initial", name.substring (0, 1). toUpperCase ());
String [] likes = new String [] ( "JavaScript", "Skiing", "Apple Pie");
jsonObj.put ( "likes", likes);
Map <String, String> ingredients = new HashMap <String, String> ();
ingredients.put ( "apples", "3kg");
ingredients.put ( "sugar", "1kg");
ingredients.put ( "pastry", "2.4kg");
ingredients.put ( "bestEaten", "outdoors");
jsonObj.put ( "ingredients", ingredients);
System.out.println (jsonObj);
System.out.println (jsonObj);
)
)
Four commonly used excessive for Filter
First, the browser does not cache pages filter
import javax.servlet .*;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/ **
* Browser does not make for the cache pages filter
* /
public class ForceNoCacheFilter implements Filter (
public void doFilter (ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException
(
((HttpServletResponse) response). SetHeader ( "Cache-Control", "no-cache");
((HttpServletResponse) response). SetHeader ( "Pragma", "no-cache");
((HttpServletResponse) response). SetDateHeader ( "Expires", -1);
filterChain.doFilter (request, response);
)
public void destroy ()
(
)
public void init (FilterConfig filterConfig) throws ServletException
(
)
)
Second, testing whether the user landing filter
import javax.servlet .*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.util.List;
import java.util.ArrayList;
import java.util.StringTokenizer;
import java.io.IOException;
/ **
* Used to detect whether the user landing filter, if unknown, then redirected to refer to the login page <p>
* Configuration parameters <p>
* CheckSessionKey need to examine the preservation of the Session of the keywords <br />
* RedirectURL unknown if the user is redirected to a specific page, URL does not include ContextPath <br/>
* NotCheckURLList not check the URL list, a semicolon to separate and not included in the URL ContextPath <br/>
* /
public class CheckLoginFilter
implements Filter
(
protected FilterConfig filterConfig = null;
private String redirectURL = null;
private List notCheckURLList = new ArrayList ();
private String sessionKey = null;
public void doFilter (ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException
(
HttpServletRequest request = (HttpServletRequest) servletRequest;
HttpServletResponse response = (HttpServletResponse) servletResponse;
HttpSession session = request.getSession ();
if (sessionKey == null)
(
filterChain.doFilter (request, response);
return;
)
if ((! checkRequestURIIntNotFilterList (request)) & & session.getAttribute (sessionKey) == null)
(
response.sendRedirect (request.getContextPath () + redirectURL);
return;
)
filterChain.doFilter (servletRequest, servletResponse);
)
public void destroy ()
(
notCheckURLList.clear ();
)
private boolean checkRequestURIIntNotFilterList (HttpServletRequest request)
(
String uri = request.getServletPath () + (request.getPathInfo () == null? "": Request.getPathInfo ());
return notCheckURLList.contains (uri);
)
public void init (FilterConfig filterConfig) throws ServletException
(
this.filterConfig = filterConfig;
redirectURL = filterConfig.getInitParameter ( "redirectURL");
sessionKey = filterConfig.getInitParameter ( "checkSessionKey");
String notCheckURLListStr = filterConfig.getInitParameter ( "notCheckURLList");
if (notCheckURLListStr! = null)
(
StringTokenizer st = new StringTokenizer (notCheckURLListStr, ";");
notCheckURLList.clear ();
while (st.hasMoreTokens ())
(
notCheckURLList.add (st.nextToken ());
)
)
)
)
Third, character encoding filters
import javax.servlet .*;
import java.io.IOException;
/ **
* To set the HTTP request character encoding filter through the filter encoding specified parameters of the character encoding used for the treatment Html Form request parameters of the Chinese problem
* /
public class CharacterEncodingFilter
implements Filter
(
protected FilterConfig filterConfig = null;
protected String encoding = "";
public void doFilter (ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException
(
if (encoding! = null)
servletRequest.setCharacterEncoding (encoding);
filterChain.doFilter (servletRequest, servletResponse);
)
public void destroy ()
(
filterConfig = null;
encoding = null;
)
public void init (FilterConfig filterConfig) throws ServletException
(
this.filterConfig = filterConfig;
this.encoding = filterConfig.getInitParameter ( "encoding");
)
)
4, resource protection filter
package catalog.view.util;
import javax.servlet.Filter;
import javax.servlet.FilterConfig;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.Iterator;
import java.util.Set;
import java.util.HashSet;
/ /
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/ **
* This Filter class handle the security of the application.
*
* It should be configured inside the web.xml.
*
* @ Author Derek Y. Shen
* /
public class SecurityFilter implements Filter (
/ / the login page uri
private static final String LOGIN_PAGE_URI = "login.jsf";
/ / the logger object
private Log logger = LogFactory.getLog (this.getClass ());
/ / a set of restricted resources
private Set restrictedResources;
/ **
* Initializes the Filter.
* /
public void init (FilterConfig filterConfig) throws ServletException (
this.restrictedResources = new HashSet ();
this.restrictedResources.add ( "/ createProduct.jsf");
this.restrictedResources.add ( "/ editProduct.jsf");
this.restrictedResources.add ( "/ productList.jsf");
)
/ **
* Standard doFilter object.
* /
public void doFilter (ServletRequest req, ServletResponse res, FilterChain chain)
throws IOException, ServletException (
this.logger.debug ( "doFilter");
String contextPath = ((HttpServletRequest) req). GetContextPath ();
String requestUri = ((HttpServletRequest) req). GetRequestURI ();
this.logger.debug ( "contextPath =" + contextPath);
this.logger.debug ( "requestUri =" + requestUri);
if (this.contains (requestUri, contextPath) & &! this.authorize ((HttpServletRequest) req)) (
&nbs
p;this.logger.debug ( "authorization failed");
((HttpServletRequest) req). GetRequestDispatcher (LOGIN_PAGE_URI). Forward (req, res);
)
else (
this.logger.debug ( "authorization succeeded");
chain.doFilter (req, res);
)
)
public void destroy () ()
private boolean contains (String value, String contextPath) (
Iterator ite = this.restrictedResources.iterator ();
while (ite.hasNext ()) (
String restrictedResource = (String) ite.next ();
if ((contextPath + restrictedResource). equalsIgnoreCase (value)) (
return true;
)
)
return false;
)
private boolean authorize (HttpServletRequest req) (
/ / Handling users log
/ * UserBean user = (UserBean) req.getSession (). GetAttribute (BeanNames.USER_BEAN);
if (user! = null & & user.getLoggedIn ()) (
/ / user logged in
return true;
)
else (
return false;
) * /
)
)
struts1 and compare struts2
Li Gang, the last to see that this part of the struts2, feeling that the upgraded version of webwork, compared with struts1 still great differences. The combination of the Internet some of the information I had to sum up slightly struts1 and struts2 the difference between:
Class Action
Struts1 the action necessary to inherit an abstract base class. Struts1 is a common problem is an abstract category for programming to replace the programming interface.
Struts2 of action can achieve an Action interface, can also achieve some other interface to acquire some additional, commonly used services. Struts2 to provide a base class ActionSupport achieve some common interface. Although the Action interface is not necessary. Any way attached to execute the POJO objects can be as Struts2 of action targets.
Servlet dependence
Struts1 dependent on the Action Servlet API, Action is called for when the time HttpServletRequest and execute HttpServletResponse object through the method of processing.
Struts2 of Action on almost does not directly dependent on the Servlet API. Servlet context was often portrayed as a simple Map mapping, Action was allowed a separate test. Of course, if need be Struts2 of Action can also visit the initial request and response to the completion of some functions. However, some other structure elements lead to lower or remove a direct response to the request and demand.
Easy test of
Struts1 test of Action is a major obstacle to execute is directly exposed to the servlet API.
Struts2 of Action can easily attribute the call by setting up methods for testing. Of course, rely on the support of injection also makes testing simple.
Enter treatment
Struts1 ActionForm object to the use of an access to user input. And action, all the ActionForm must be inherited from a base class. Because the other can not be used as the javaBean ActionForm, developers usually write some extra class to obtain user input. DynaBean can be used to generate ActionForm kind of a choice, but developers need to rewrite the existing javaBean.
Struts2 use of Action attributes as input attributes, get rid of the demand for the importation of objects. Enter attribute can be an owner of his own attributes of objects. Action by tags and attributes are interactive web pages. Struts2 also support ActionForm model, is the Form POJO objects and POJO of Action. Most of the type of person, including targets and areas of business logic object can be used as input / output targets. Models Driver features simplified labels and POJO enter the relationship between objects.
Expression language
Struts1 and JSTL integration, so he can use JSTL the EL.
Struts2 also support JSTL, but this framework also supports a stronger expression of language OGNL.
The type of performance and value of bundled
Struts1 using standard JSP mechanism would bind to the target page context to his visit.
Struts2 use "ValueStack" technology, so do not have to label the view of the target and performance can get value. ValueStack policy allows through a series of attributes may have the same name
But the word different types of properties to complete view of the type of reuse.
Type -
Struts1 the ActionForm are usually String type. Struts1 through the Commons-Beanutils achieve conversion.
Struts2 use OGNL achieve conversion, the framework includes the foundation and public types of converters.
Authentication
Struts1 support ActionForm validate method of manual verification. You can also verify the extension of universal framework for validation. For the same category can have a different verification, but not linked to the object of verification.
Struts2 also supported by validate methods for manual verification and validation Xwork framework for validation. Xwork certification framework will support the verification link to sub-attributes, sub-attributes to the use of the property type and verify the context of the definition of certification.
The implementation of the Action Control
Struts1 support for each module allocation request processing (life cycle), but a module of Action must all share the same life cycle.
Struts2 support the passage of the interceptor stack for each Action create a different life-cycle. Action is usually based on the different needs of the corresponding stack must have been created and used.
Hashtable and the difference between HashMap
1.Hashtable Dictionary is a sub-category, HashMap Map interface is a realization;
2.Hashtable is in sync, and the HashMap in the way in default under the non-synchronized. In other words, the multi-threaded applications, no special operation on security and can use the Hashtable, and the HashMap, the need for additional synchronization mechanisms. However, the synchronization HashMap Collections through a static approach to solve:
Map Collections.synchronizedMap (Map m)
This method returns a synchronized Map, Map of this package the bottom of the HashMap all the way, making the bottom of the HashMap even in the multi-threaded environment is safe.
3. HashMap in, null can be used as keys, so there is only one of the keys; can have one or more keys corresponding to the value of null. When the get () method returns null value, which can be said HashMap in the absence of the key, can also be said that the key corresponding to the value of null. Therefore, in the HashMap can not get () method to determine whether there is a HashMap in the key, but should be used containsKey () method to judge.
4.HashTable use Enumeration, HashMap use Iterator.
These are just a different surface, they are also the realization are quite different.
5.HashTable in the hash array default size is 11, the increase is way old * 2 +1. HashMap array of hash the default size is 16, but must be two of the index.
6. Hash value of the use of different, HashTable used directly targeted hashCode, the code is as follows:
int hash = key.hashCode ();
int index = (hash & 0x7FFFFFFF)% tab.length;
The HashMap re-hash value, but instead of using and seeking mode:
int hash = hash (k);
int i = indexFor (hash, table.length);
static int hash (Object x) (
Int h = x.hashCode ();
H + = ~ (h <<9);
H ^ = (h>>> 14);
H + = (h <<4);
H ^ = (h>>> 10);
Return h;
)
static int indexFor (int h, int length) (
Return h & (length-1);
)
singleton pattern
singleton pattern
In a system requirements for a class when there is only one example of single-mode should be used. Conversely, if a class can have several examples of coexistence, it is not necessary to use the single case of type.
For example, tools, window manager, print buffer pool and file system, and they are the prototype examples.
1.
package singleton;
public class Singleton (
private static final Singleton st = new Singleton ();
private Singleton () (
)
public static Singleton getInstance () (
return st;
)
public void out () (
System.out.println ( "singleton");
)
)
2.
package singleton;
public class SingletonMain (
public static void main (String [] args) (
Singleton st1 = Singleton.getInstance ();
Singleton st2 = Singleton.getInstance ();
System.out.println (st1 == st2);
st1.out ();
st2.out ();
)
)
struts2 label
struts2 label
Used struts1.x people are aware that the labels are html, bean, logic, tiles,
Struts2.0, and the label is not classified, only the first document with the jsp
<% @ Taglib prefix = "s" uri = "/ struts-tags"%>
Will be able to use the label for struts2.0
Below each tab on the introduction of the use of (correction is wrong please):
A:
<s:a xhref=""> </ s: a >—– hyperlinks, similar to html in the <a> </ a>
<s:action name=""> </ s: action >—– implementation of a view inside of a action
<s:actionerror/> —– action if the errors are values that are displayed
<s:actionmessage/> —– action if the message is then displayed value
<s:append> </ s: append >—– add a value to the list, similar to list.add ();
<s:autocompleter> </ s: autocompleter >—– automatically <s: combobox> label the content, this is ajax
B:
<s:bean name=""> </ s: bean >—– similar to the struts1.x, JavaBean value
C:
<s:checkbox> </ s: checkbox >—– box
<s:checkboxlist list=""> </ s: checkboxlist >—– checkbox
<s:combobox list=""> </ s: combobox >—– drop-down box
<s:component> </ s: component >—– image symbols
D:
<s:date/> —– acquisition date format
<s:datetimepicker> </ s: datetimepicker >—– date input box
<s:debug> </ s: debug >—– display an error message
<s:div> </ s: div >—– that a block, similar to the html <div> </ div>
<s:doubleselect list="" doubleName="" doubleList=""> </ s: doubleselect >—– double drop-down box
E:
<s:if test=""> </ s: if>
<s:elseif test=""> </ s: elseif>
<s:else> </ s: else >—– this three labels used together, the judge said conditions
F:
<s:fielderror> </ s: fielderror >—– file error
<s:file> </ s: file >—– file upload
<s:form action=""> </ s: form >—– access to the value of the corresponding form
G:
<s:generator separator="" val=""> </ s: generator >—- and <s: iterator> labels to use
H:
<s:head/> —– in the <head> </ head> in use, said the end of the first paper
<s:hidden> </ s: hidden >—– hidden value
I:
<s:i18n name=""> </ s: i18n >—– load resources-to value stack
<s:include value=""> </ s: include >—– includes an output, servlet or jsp pages
<s:inputtransferselect list=""> </ s: inputtransferselect >—– access to a form of input
<s:iterator> </ s: iterator >—– used to traverse the collection
L:
<s:label> </ s: label >—– read-only label
M:
<s:merge> </ s: merge >—– set up a joint traversal of the value
O:
<s:optgroup> </ s: optgroup >—– Group label obtain
<s:optiontransferselect doubleList="" list="" doubleName=""> </ s: optiontransferselect >—– about the selection box
P:
<s:param> </ s: param >—– provide parameters for other labels
<s:password> </ s: password >—– password input box
<s:property/> —– be 'value' properties
<s:push value=""> </ s: push >—– value of the push to stack so that the label to acquire property value of property
R:
<s:radio list=""> </ s: radio >—– radio button
<s:reset> </ s: reset >—– reset button
S:
<s:select list=""> </ s: select >—– single-box
<s:set name=""> </ s: set >—– give a specific variables within the scope of value
<s:sort comparator=""> </ s: sort >—– attribute to the list by Category
<s:submit> </ s: submit >—– submit button
<s:subset> </ s: subset >—– to traverse a subset of the collection output
T:
<s:tabbedPanel id=""> </ s: tabbedPanel >—– form box
<s:table> </ s: table >—– form
<s:text name=""> </ s: text >—– I18n text messages
<s:textarea> </ s: textarea >—– text input box domain
<s:textfield> </ s: textfield >—– text input box
<s:token> </ s: token >—– blocker
<s:tree> </ s: tree >—– tree
<s:treenode label=""> </ s: treenode >—– tree structure
U:
<s:updownselect list=""> </ s: updownselect >—– more selection box
<s:url> </ s: url >—– create a url
struts2 the FilterDispatcher
1: In the category of a property FilterDispatcher
private static boolean serveStatic;
private static ActionMapper actionMapper;
These two properties through the injection of a Container Vessels
struts-default.xml in <bean class = "org.apache.struts2.dispatcher.FilterDispatcher" static = "true" /> such a
Is injected into static properties.
And then go to visit doFilter methods in the url have no corresponding ActionMapping (storage Action)
If it does not go to static resources, the way in the init
String packages = "org.apache.struts2.static template org.apache.struts2.interceptor.debugging";
Can also configure their own packages in web.xml attribute
Then you can visit in a browser in org.apache.struts2.static, template, org.apache.struts2.interceptor.debugging
, web.xml configuration packages in the property, visited resources, but uri to begin to struts
For example, I would like to visit the org.apache.struts2.static optiontransferselect.js (jar will be able to extract the files to see)
/ struts / optiontransferselect.js will be able to download this js
2:
finally (
try (
ActionContextCleanUp.cleanUp (req);
) Finally (
UtilTimerStack.pop (timerKey);
)
)
ActionContextCleanUp the way doFilter
finally (
int counterVal = ((Integer) request.getAttribute (COUNTER)). intValue ();
counterVal -= 1;
request.setAttribute (COUNTER, new Integer (counterVal));
cleanUp (request);
)
ActionContextCleanUp cleanUp method of cleaning up the resources
ActionContext.setContext (null);
Dispatcher.setInstance (null);
Action was in Container
Action was in Container
public String execute () throws Exception (
ActionContext context = ActionContext.getContext ();
HttpServletRequest request = (HttpServletRequest) context.get (StrutsStatics.HTTP_REQUEST);
/ / By Constant
/ *
struts.xml in <constant name = "gloabName" value = "I love the band spent 3"> </ constant>
* /
Dispatcher dispatch = (Dispatcher) Dispatcher.getInstance ();
Container container = dispatch.getContainer ();
String global = container.getInstance (String.class, "gloabName");
/ / Can also receive all the struts-default.xml label bean implementation class
System.out.println ( "configuration ========="+ container.getInstance (Configuration.class));
System.out.println ( "gloabName ==========" + global);
return SUCCESS;
)
/ / In fact, the init method FilterDispatcher put all these into the Container in the
jsunit flash ppt complete code examples can be run
jsunit flash ppt + complete code examples can be run
File Name: Jsunit Demo.zip
URL: http://www.fs2you.com/files/0df4fa4a-4e22-11dd-bdeb-0014221f4662/
Download the cabinet down, to extract the directory c Pan-gen, you can also extract to other places, but to amend the build.xml inside path. Firefox installed inside the path is in default of the C-Program Files directory, if you installed in other places, but also to modify. After the extract, direct access to JsUnitAnt directory, run ant target, that is, ant JsUnitTest. Firefox browser will open automatically, called the tests directory testRunner.html, will then test jsUnitTestSuite.html inside the designated testcases,
After the operation, if progress is to green, that all through the test, otherwise it will show which testcase failed. The results will be stored in the form of xml logs directory.