請服用
http://www.sergiy.ca/how-to-iterate-over-a-map-in-java
//get current user
String currentUser = AuthenticationUtil.getFullyAuthenticatedUser();
String fakeUser = "IAMBIGD";
LOGGER.debug("currentUser:" + currentUser);
if (currentUser == null || !currentUser.equals(fakeUser)) {
// AuthenticationUtil.setCurrentUser(username);
//set impersonate
AuthenticationUtil.setFullyAuthenticatedUser(fakeUser);
}
app.directive('validFile',function(){
return {
require:'ngModel',
link:function(scope,el,attrs,ngModel){
//change event is fired when file is selected
el.bind('change',function(){
scope.$apply(function(){
ngModel.$setViewValue(el.val());
ngModel.$render();
});
});
}
}
});
Input is valid: {{myForm.userUpload.$valid}} Selected file: {{filename}}
//設定某個物件被選擇
ng-class="{true: 'table-row-selected', false: ''}[product.selected]"
//取得被選擇的使用者數量
$scope.getSelectedUsers = function() {
var selectedObjs = $filter("filter")($scope.userList, {
selected: true
})
return selectedObjs;
};
//html ng-repeat="folder in parentFolders.slice().reverse()
$location.path('/login');
$window.open('http://www.yahoo.com.tw');
$scope.userList.splice($index, 1);//移除使用者清單內的某一用戶
app.run(['$http', function($http) {
// The $http service will automatically add certain HTTP headers to all requests. These defaults can be fully configured by accessing the $httpProvider.defaults.headers configuration object, which currently contains this default configuration:
// $httpProvider.defaults.headers.common (headers that are common for all requests):
// Accept: application/json, text/plain, * / *
// $httpProvider.defaults.headers.post: (header defaults for POST requests)
// Content-Type: application/json
// $httpProvider.defaults.headers.put (header defaults for PUT requests)
// Content-Type: application/json
$http.defaults.headers.common['Content-Type'] = 'application/json';
}])
$scope.$watch('form', function(newVal, oldVal){
console.log('changed');
}, true);
app.run(['$templateCache',function($templateCache){
$templateCache.removeAll();
}]);
import urllib.request,os,hashlib; h = '7183a2d3e96f11eeadd761d777e62404' + 'e330c659d4bb41d3bdf022e94cab3cd0'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); by = urllib.request.urlopen( 'http://sublime.wbond.net/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); print('Error validating download (got %s instead of %s), please try manual install' % (dh, h)) if dh != h else open(os.path.join( ipp, pf), 'wb' ).write(by)
Filter and there are great explanation and example in StackOverflow Servlet-Filter wiki.needsAuthenticationmethod):@WebFilter("/*")
public class LoginFilter implements Filter {
@Override
public void init(FilterConfig config)
throws ServletException {
// If you have any in web.xml, then you could get them
// here by config.getInitParameter("name") and assign it as field.
}
@Override
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
throws IOException, ServletException {
HttpServletRequest request = (HttpServletRequest) req;
HttpServletResponse response = (HttpServletResponse) res;
HttpSession session = request.getSession(false);
String requestPath = httpServletRequest.getRequestURI();
if (needsAuthentication(requestPath) ||
session == null ||
session.getAttribute("user") == null) { // change "user" for the session attribute you have defined
response.sendRedirect(request.getContextPath() + "/login"); // No logged-in user found, so redirect to login page.
} else {
chain.doFilter(req, res); // Logged-in user found, so just continue request.
}
}
@Override
public void destroy() {
// If you have assigned any expensive resources as field of
// this Filter class, then you could clean/close them here.
}
//basic validation of pages that do not require authentication
private boolean needsAuthentication(String url) {
String[] validNonAuthenticationUrls =
{ "Login.jsp", "Register.jsp" };
for(String validUrl : validNonAuthenticationUrls) {
if (url.endsWith(validUrl)) {
return false;
}
}
return true;
}
}
app and then change the web filter to@WebFilter("/app/*")
needsAuthentication method from the filter.module.directive('selectOnClick', function () {
return {
restrict: 'A',
link: function (scope, element, attrs) {
element.on('click', function () {
this.select();
});
}
};
});