答:
I'm not convinced the class itself is the right place to count how many you have. But there's not enough information in your question to make a good assessment of the broader goal.

As far as what you're asking goes, you have lots of options. Here are a couple…

One simple approach would be for the base class to have a dictionary:

```<code>class Animal
{
    private static readonly Dictionary<Type, int> _counts =
        new Dictionary<Type, int>();

    protected Animal()
    {
        int count;

        _counts.TryGetValue(this.GetType(), out count);
        _counts[this.GetType()] = count + 1;
    }
}

class Dog : Animal { ... }
</code>```

Another option would be to let the runtime handle the type-specific counts:

```<code>class Animal<T>
{
    private static int _count;

    protected Animal()
    {
        _count++;
    }
}

class Dog : Animal<Dog> { ... }
</code>```

To elaborate on this second option, since it may be a bit confusing to someone new to C#. Starting with your comment…

What is the <T> that you have there?

That's part of the declaration of the Animal<T> class, which makes it a generic class. That is, the class, when used, must be provided a type parameter (i.e. the name of some other type), where that type parameter specializes the generic type in a useful way (where "useful" depends on exactly how you're using it). In this particular case, my example makes the base class generic, to take advantage of the fact that static fields of a generic type are unique for each different type parameter that is used.

That is, for the declared class class Dog : Animal<Dog> { ... }, the field _count in the base class is actually a different variable than for some other declared class, e.g. class Cat : Animal<Cat> { ... }. In that way, each subclass such as Dog, Cat, etc. gets their own value for that field.

In either case, you still need to work out how you'd like to actually be able to get the counts and use them. It's not clear from your question how that fits in.

Note also that none of the above is thread-safe, while static members typically are expected to be. I've omitted that part, but you'll want to add synchronization to ensure thread-safety, so there are no surprises.

All of that said, if this is in fact over your head, and you are in fact just starting to learn about OOP, inheritance, and C#, I would go back to my original statement, that I'm not convinced implementing this in the class itself is actually the right place.

A better approach would be to have some other class that knows about the different Animal objects you are creating, and which keeps track of them in some way. For example, it could have a Dictionary<Type, List<Animal>>, where the key Type can be e.g. typeof(Dog), typeof(Cat), etc. and the value List<Animal> can just be a list of the particular type of Animal object. Then not only do you have immediate access to the count (since the List<T> class has a Count property), you can also immediately retrieve all of the objects you created.

I can't be more specific than that because, again, your question is fairly vague about what you are actually going to do with these objects. If all you're trying to do is to learn about OOP and how inheritance works, maybe it's better to just not worry about the count of objects you create for now. There's still plenty of other stuff you could focus on which will still give you substance to think about. :)

Title: Static variable to change in a child class from a parent

Body:
I'm not convinced the class itself is the right place to count how many you have. But there's not enough information in your question to make a good assessment of the broader goal.

As far as what you're asking goes, you have lots of options. Here are a couple…

One simple approach would be for the base class to have a dictionary:

class Animal
{
    private static readonly Dictionary<Type, int> _counts =
        new Dictionary<Type, int>();

    protected Animal()
    {
        int count;

        _counts.TryGetValue(this.GetType(), out count);
        _counts[this.GetType()] = count + 1;
    }
}

class Dog : Animal { ... }

Another option would be to let the runtime handle the type-specific counts:

class Animal<T>
{
    private static int _count;

    protected Animal()
    {
        _count++;
    }
}

class Dog : Animal<Dog> { ... }

To elaborate on this second option, since it may be a bit confusing to someone new to C#. Starting with your comment…

What is the <T> that you have there?

That's part of the declaration of the Animal<T> class, which makes it a generic class. That is, the class, when used, must be provided a type parameter (i.e. the name of some other type), where that type parameter specializes the generic type in a useful way (where "useful" depends on exactly how you're using it). In this particular case, my example makes the base class generic, to take advantage of the fact that static fields of a generic type are unique for each different type parameter that is used.

That is, for the declared class class Dog : Animal<Dog> { ... }, the field _count in the base class is actually a different variable than for some other declared class, e.g. class Cat : Animal<Cat> { ... }. In that way, each subclass such as Dog, Cat, etc. gets their own value for that field.

In either case, you still need to work out how you'd like to actually be able to get the counts and use them. It's not clear from your question how that fits in.

Note also that none of the above is thread-safe, while static members typically are expected to be. I've omitted that part, but you'll want to add synchronization to ensure thread-safety, so there are no surprises.

All of that said, if this is in fact over your head, and you are in fact just starting to learn about OOP, inheritance, and C#, I would go back to my original statement, that I'm not convinced implementing this in the class itself is actually the right place.

A better approach would be to have some other class that knows about the different Animal objects you are creating, and which keeps track of them in some way. For example, it could have a Dictionary<Type, List<Animal>>, where the key Type can be e.g. typeof(Dog), typeof(Cat), etc. and the value List<Animal> can just be a list of the particular type of Animal object. Then not only do you have immediate access to the count (since the List<T> class has a Count property), you can also immediately retrieve all of the objects you created.

I can't be more specific than that because, again, your question is fairly vague about what you are actually going to do with these objects. If all you're trying to do is to learn about OOP and how inheritance works, maybe it's better to just not worry about the count of objects you create for now. There's still plenty of other stuff you could focus on which will still give you substance to think about. :)


来源: stackexchange

问:
How to remove the space caused by Adsense ads while passing data from website to application?
My code is:

```<code>import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.webkit.WebChromeClient;
import android.webkit.WebView;

import com.app.asiannews.model.Post;

public class ActivityWebView extends AppCompatActivity {

    public static final String EXTRA_OBJC = "key.EXTRA_OBJC";

    private Toolbar toolbar;
    private ActionBar actionBar;

    private WebView webView;
    private Post post;
    private View parent_view;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_webview);
        parent_view = findViewById(android.R.id.content);

        webView = (WebView) findViewById(R.id.webView);

        // get extra object
        post = (Post) getIntent().getSerializableExtra(EXTRA_OBJC);
        initToolbar();
        loadWebFromUrl();

        // analytics tracking
        ThisApplication.getInstance().trackScreenView("WebView : "+post.title_plain);
    }

    private void initToolbar() {
        toolbar = (Toolbar) findViewById(R.id.toolbar);
        toolbar.setTitleTextAppearance(this, android.R.style.TextAppearance_Material_Subhead);
        setSupportActionBar(toolbar);
        actionBar = getSupportActionBar();
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setHomeButtonEnabled(true);
        actionBar.setTitle(R.string.activity_title_webview);
    }

    private void loadWebFromUrl() {
        webView.loadUrl("about:blank");
        webView.getSettings().setJavaScriptEnabled(true);
        webView.getSettings();
        webView.getSettings().setBuiltInZoomControls(true);
        webView.loadUrl(post.url);
        webView.setWebChromeClient(new WebChromeClient() {
            public void onProgressChanged(WebView view, int progress) {
                actionBar.setTitle( getString(R.string.webview_loading) + progress + " %");
                if (progress == 100) {
                    actionBar.setTitle(R.string.activity_title_webview);
                }
            }
        });
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        if (item.getItemId() == android.R.id.home) {
            onBackPressed();
        } else if (item.getItemId() == R.id.action_refresh) {
            loadWebFromUrl();
        }
        return super.onOptionsItemSelected(item);
    }
</code>```

I have added my code as shown above. There is space caused by the adsense ads which are implemetnted in the website. Now the problem is how to remove it.

My screen

Please give me the solution regarding it

答:
You need to append the meta tag along with my HTML content before adding it to the Webview. Please find the Code below</p>

```<code> String s="<head><meta name='viewport' content='target-densityDpi=device-dpi'/></head>";
 webview.loadDataWithBaseURL(null,s+htmlContent,"text/html" , "utf-8",null);
</code>```

ContentLicense: CC BY-SA 3.0

Body:
My code is:

import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.webkit.WebChromeClient;
import android.webkit.WebView;

import com.app.asiannews.model.Post;

public class ActivityWebView extends AppCompatActivity {

    public static final String EXTRA_OBJC = "key.EXTRA_OBJC";

    private Toolbar toolbar;
    private ActionBar actionBar;

    private WebView webView;
    private Post post;
    private View parent_view;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_webview);
        parent_view = findViewById(android.R.id.content);

        webView = (WebView) findViewById(R.id.webView);

        // get extra object
        post = (Post) getIntent().getSerializableExtra(EXTRA_OBJC);
        initToolbar();
        loadWebFromUrl();

        // analytics tracking
        ThisApplication.getInstance().trackScreenView("WebView : "+post.title_plain);
    }

    private void initToolbar() {
        toolbar = (Toolbar) findViewById(R.id.toolbar);
        toolbar.setTitleTextAppearance(this, android.R.style.TextAppearance_Material_Subhead);
        setSupportActionBar(toolbar);
        actionBar = getSupportActionBar();
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setHomeButtonEnabled(true);
        actionBar.setTitle(R.string.activity_title_webview);
    }

    private void loadWebFromUrl() {
        webView.loadUrl("about:blank");
        webView.getSettings().setJavaScriptEnabled(true);
        webView.getSettings();
        webView.getSettings().setBuiltInZoomControls(true);
        webView.loadUrl(post.url);
        webView.setWebChromeClient(new WebChromeClient() {
            public void onProgressChanged(WebView view, int progress) {
                actionBar.setTitle( getString(R.string.webview_loading) + progress + " %");
                if (progress == 100) {
                    actionBar.setTitle(R.string.activity_title_webview);
                }
            }
        });
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        if (item.getItemId() == android.R.id.home) {
            onBackPressed();
        } else if (item.getItemId() == R.id.action_refresh) {
            loadWebFromUrl();
        }
        return super.onOptionsItemSelected(item);
    }

I have added my code as shown above. There is space caused by the adsense ads which are implemetnted in the website. Now the problem is how to remove it.

My screen

Please give me the solution regarding it

Body:
You need to append the meta tag along with my HTML content before adding it to the Webview. Please find the Code below

 String s="<head><meta name='viewport' content='target-densityDpi=device-dpi'/></head>";
 webview.loadDataWithBaseURL(null,s+htmlContent,"text/html" , "utf-8",null);


问:
How to make a button not show up but still be used by javascript?
I am using a button that has to be invible and should be used by a javascript function.

```<code><asp:Button ID ="btnDummy1" runat="server" Visible ="true" OnClick="btnSubmit1_Click" width="0px" height="0px"/
</code>```

I cannot keep visible = false as it the javascript will not use invible content in the poage. I havetried to give width=0 and height=0, still it showws up in Chrome. What do you guys think i should do?

Thanks in advance :)

答:
Can you just use a hidden form field in this case? This is generally the preferred method of passing information along.

See http://www.tizag.com/htmlT/htmlhidden.php

ContentLicense: CC BY-SA 2.5

Body:
I am using a button that has to be invible and should be used by a javascript function.

<asp:Button ID ="btnDummy1" runat="server" Visible ="true" OnClick="btnSubmit1_Click" width="0px" height="0px"/

I cannot keep visible = false as it the javascript will not use invible content in the poage. I havetried to give width=0 and height=0, still it showws up in Chrome. What do you guys think i should do?

Thanks in advance :)


问:
How to check more gently that some part of the code running 4 times a day
I have the script running by crontab and I want some part of the code being executed 4 times a day.

I have the snippet of code which

```<code>from datetime import datetime, time
now = datetime.now()
now_time = now.time()
if now_time == time(10,00) or now_time == time(16,00) or now_time == time(22,00) or now_time == time (4,00):
    func()
</code>```

The minus of this solution is that this part of the code may be executed on 10.01, 10.02 and will be skipped this way.

Is there more gentle and shorter way to write down this part of code?

Thanks!

答:
I see two ways to solve the problem.

1) Use the global variable as a counter

```<code>numOfCalls = 0
#for every func() call
func()
numOfCalls = numOfCalls + 1
</code>```

2) Every time function is executed, time stamp and func name might be written to some log file

```<code>from datetime import datetime, time
current_time = datetime.now().time()

with open("log.txt", "a") as myfile:
    myfile.write("func " + str(current_time) + "\n")
</code>```

Body:
I have the script running by crontab and I want some part of the code being executed 4 times a day.

I have the snippet of code which

from datetime import datetime, time
now = datetime.now()
now_time = now.time()
if now_time == time(10,00) or now_time == time(16,00) or now_time == time(22,00) or now_time == time (4,00):
    func()

The minus of this solution is that this part of the code may be executed on 10.01, 10.02 and will be skipped this way.

Is there more gentle and shorter way to write down this part of code?

Thanks!

Body:
I see two ways to solve the problem.

1) Use the global variable as a counter

numOfCalls = 0
#for every func() call
func()
numOfCalls = numOfCalls + 1

2) Every time function is executed, time stamp and func name might be written to some log file

from datetime import datetime, time
current_time = datetime.now().time()

with open("log.txt", "a") as myfile:
    myfile.write("func " + str(current_time) + "\n")


问:
How to input data into MySQL from Eclipse
I'm trying to input data into MySQL database through eclipse. Here's what I have so far:

```<code>import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.PreparedStatement;
import com.mysql.jdbc.Statement;

public class MySQL{

public static void main(String[] args)throws Exception{

    Class.forName("com.mysql.jdbc.Driver");

    Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/database","root","root");

    PreparedStatement stmt = con.prepareStatement("INSERT INTO 'database'.'Table'(Account_ID,First_Name,Last_Name) VALUES ('hello12','Ed','Lee')");

    ResultSet result = stmt.executeQuery();}

 }
</code>```

It doesn't work for some reason...any ideas?

答:
Change the following line

```<code>PreparedStatement stmt = con.prepareStatement("INSERT INTO 'database'.'Table'(Account_ID,First_Name,Last_Name) VALUES ('hello12','Ed','Lee')");
</code>```

to

```<code>PreparedStatement stmt = con.prepareStatement("INSERT INTO `database`.`Table`(Account_ID,First_Name,Last_Name) VALUES ('hello12','Ed','Lee')");
</code>```

the single quotes used for the database name and the table name will throw a syntax error. Instead use ` this symbol.

Body:
I'm trying to input data into MySQL database through eclipse. Here's what I have so far:

import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.PreparedStatement;
import com.mysql.jdbc.Statement;

public class MySQL{

public static void main(String[] args)throws Exception{

    Class.forName("com.mysql.jdbc.Driver");

    Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/database","root","root");

    PreparedStatement stmt = con.prepareStatement("INSERT INTO 'database'.'Table'(Account_ID,First_Name,Last_Name) VALUES ('hello12','Ed','Lee')");

    ResultSet result = stmt.executeQuery();}

 }

It doesn't work for some reason...any ideas?

Body:
Change the following line

PreparedStatement stmt = con.prepareStatement("INSERT INTO 'database'.'Table'(Account_ID,First_Name,Last_Name) VALUES ('hello12','Ed','Lee')");

to

PreparedStatement stmt = con.prepareStatement("INSERT INTO `database`.`Table`(Account_ID,First_Name,Last_Name) VALUES ('hello12','Ed','Lee')");

the single quotes used for the database name and the table name will throw a syntax error. Instead use ` this symbol.


问:
Generic type 'Component
' requires 2 type argument(s)
I'm trying to use ts and react-router v4 to make a demo, and I will get the error.

```<code>Failed to compile.

Error in D:\data\code\taven\react-components-usage-ts\node_modules\@types\react-router\lib\withRouter.d.ts

(3,99): error TS2314: Generic type 'PureComponent<P, S>' requires 2 type argument(s).
</code>```

答:
Are you using React-Redux? This was updated a few days ago. I had to revert back to an older version.

https://github.com/DefinitelyTyped/DefinitelyTyped/blame/master/types/react-redux/index.d.ts#L179

This version worked for me.
"@types/react-redux": "4.4.32"

Title: Generic type 'Component<P, S>' requires 2 type argument(s)

Body:
I'm trying to use ts and react-router v4 to make a demo, and I will get the error.

Failed to compile.

Error in D:\data\code\taven\react-components-usage-ts\node_modules\@types\react-router\lib\withRouter.d.ts

(3,99): error TS2314: Generic type 'PureComponent
' requires 2 type argument(s).


问:
NoMethodError in Users#new "undefined method `simple_form_for' for #<#<Class:0x9f9b568>:0xaa02440>"
My new.html.erb code in views/users:

```<code> <h1>Sign Up</h1>

 <%= simple_form_for(@user) do |f| %>
 <%= f.input :username %>
 <%= f.input :password %>
 <%= f.input :password_confirmation %>
 <%= f.button :submit %>
 <% end %>
</code>```

this is the error:

```<code> undefined method `simple_form_for' for #<#<Class:0x9f9b568>:0xaa02440>
</code>```

I know what this error is asking for:

```<code> def simple_form_for
 end
</code>```

but the problem is where to put it.
Also this is my users_controller.rb:

```<code> class UsersController < ApplicationController
     def new
          @user = User.new
     end

     def create
         @user = User.new(params[:user])
         if @user.save
             redirect_to @user, notice: 'User was successfully created.'
         else
             render action: "new"
         end
     end

     def show
         @user = User.find(params[:id])
     end
 end
</code>```

答:
Gemfile: gem 'bootstrap-sass'

         gem 'simple_form'

you must have a setting for bootstrap
"rails generate simple_form:install --bootstrap"

Body:
My new.html.erb code in views/users:

Sign Up

 <%= simple_form_for(@user) do |f| %>
 <%= f.input :username %>
 <%= f.input :password %>
 <%= f.input :password_confirmation %>
 <%= f.button :submit %>
 <% end %>

this is the error:

 undefined method `simple_form_for' for #<#<Class:0x9f9b568>:0xaa02440>

I know what this error is asking for:

 def simple_form_for
 end

but the problem is where to put it.
Also this is my users_controller.rb:

 class UsersController < ApplicationController
     def new
          @user = User.new
     end

     def create
         @user = User.new(params[:user])
         if @user.save
             redirect_to @user, notice: 'User was successfully created.'
         else
             render action: "new"
         end
     end

     def show
         @user = User.find(params[:id])
     end
 end

ContentLicense: CC BY-SA 4.0


问:
Run function after page load but NOT refresh
I have a jquery function I want to run ONLY when a page is loaded the first time, not after a refresh.

Here's the code:

```<code>$(window).on("load",function() {
    $("#logo-black").typed({
        strings: ["Nothing^450&Co^250.^500", "^800__^400&Co^600."],
        typeSpeed: 70,
        backSpeed: 100,
    callback: function() {
        $(".typed-cursor").css("display", "none"),
        setTimeout(function(){
            $('.main-load').toggleClass('main-load-active'),
            $('.nav-text').toggleClass('nav-text-active');
        },400),
        $('.nav-reveal').toggleClass('nav-reveal-active');
        }
    });
});
</code>```

A few things to note:
-I'm using barba.js, so content is added/removed via AJAX.

Code that initializes barba.js for my project:

```<code>initFullpagePlugin();

function initFullpagePlugin (parentElement) {
var element;

element = parentElement ? $('#fullpage', parentElement) :
$('#fullpage');

if (element.length) {

  // Destroys old fullPage.js object in memory,
  // removes elements from DOM
  if ($.fn.fullpage.destroy) {
    $.fn.fullpage.destroy('all');
  }
  element.fullpage({
    //Scrolling
    autoScrolling:false,
    scrollingSpeed: 2500,
    easing: 'swing',
    fitToSection: false
  });
}
}

document.addEventListener("DOMContentLoaded", function() {
if (!('webkitClipPath' in document.body.style)) {
alert('Sorry, this demo is available just with webkitClipPath. Try with
Chrome/Safari.');
}

Barba.Pjax.init();
Barba.Prefetch.init();

var FadeTransition = Barba.BaseTransition.extend({
start: function() {
/**
 * This function is automatically called as soon the Transition starts
 * this.newContainerLoading is a Promise for the loading of the new
container
 * (Barba.js also comes with an handy Promise polyfill!)
 */

// As soon the loading is finished and the old page is faded out, let's
fade the new page
Promise
  .all([this.newContainerLoading, this.fadeOut()])
  .then(this.fadeIn.bind(this));
},

fadeOut: function() {
/**
 * this.oldContainer is the HTMLElement of the old Container
 */

return $(this.oldContainer).animate({ opacity: 0 }).promise();
},

fadeIn: function() {
/**
 * this.newContainer is the HTMLElement of the new Container
 * At this stage newContainer is on the DOM (inside our #barba-
container and with visibility: hidden)
 * Please note, newContainer is available just after
newContainerLoading is resolved!
 */
document.body.scrollTop = 0;
var _this = this;
var $el = $(this.newContainer);

$(this.oldContainer).hide();

$el.css({
  visibility : 'visible',
  opacity : 0
});

initFullpagePlugin($el);

$el.animate({ opacity: 1 }, 400, function() {
  /**
   * Do not forget to call .done() as soon your transition is finished!
   * .done() will automatically remove from the DOM the old Container
   */
  _this.done();
});
}
});

/**
* Next step, you have to tell Barba to use the new Transition
*/

Barba.Pjax.getTransition = function() {
/**
 * Here you can use your own logic!
 * For example you can use different Transition based on the current
 page or link...
 */

 return FadeTransition;
 };
});

$('.no-click').on("click", function(e) {
e.preventDefault();
});
</code>```

For instance, this design studio has an animation that runs when you first load the home page, but not after a refresh. (NOTE: this seems to only apply to the mobile version, but it's what I'm trying to achieve. The element I'm animating is present on every page, so making sure it only fires on first load & ONLY on the index.html is something I'm shooting for)

Any help/suggestions/constructive criticism is appreciated!

答:
You can use the transitionCompleted function to load your script.

```<code>Barba.Dispatcher.on('transitionCompleted', function(currentStatus, prevStatus) {

    if (prevStatus) {
        setTimeout(function() {

            // call your script

        }, 1000);
    }

});
</code>```

Remember that the barba.js event transitionCompleted is fired each time a new page is loaded.

Body:
I have a jquery function I want to run ONLY when a page is loaded the first time, not after a refresh.

Here's the code:

$(window).on("load",function() {
    $("#logo-black").typed({
        strings: ["Nothing^450&Co^250.^500", "^800__^400&Co^600."],
        typeSpeed: 70,
        backSpeed: 100,
    callback: function() {
        $(".typed-cursor").css("display", "none"),
        setTimeout(function(){
            $('.main-load').toggleClass('main-load-active'),
            $('.nav-text').toggleClass('nav-text-active');
        },400),
        $('.nav-reveal').toggleClass('nav-reveal-active');
        }
    });
});

A few things to note:
-I'm using barba.js, so content is added/removed via AJAX.

Code that initializes barba.js for my project:

initFullpagePlugin();

function initFullpagePlugin (parentElement) {
var element;

element = parentElement ? $('#fullpage', parentElement) :
$('#fullpage');

if (element.length) {

  // Destroys old fullPage.js object in memory,
  // removes elements from DOM
  if ($.fn.fullpage.destroy) {
    $.fn.fullpage.destroy('all');
  }
  element.fullpage({
    //Scrolling
    autoScrolling:false,
    scrollingSpeed: 2500,
    easing: 'swing',
    fitToSection: false
  });
}
}

document.addEventListener("DOMContentLoaded", function() {
if (!('webkitClipPath' in document.body.style)) {
alert('Sorry, this demo is available just with webkitClipPath. Try with
Chrome/Safari.');
}

Barba.Pjax.init();
Barba.Prefetch.init();

var FadeTransition = Barba.BaseTransition.extend({
start: function() {
/**
 * This function is automatically called as soon the Transition starts
 * this.newContainerLoading is a Promise for the loading of the new
container
 * (Barba.js also comes with an handy Promise polyfill!)
 */

// As soon the loading is finished and the old page is faded out, let's
fade the new page
Promise
  .all([this.newContainerLoading, this.fadeOut()])
  .then(this.fadeIn.bind(this));
},

fadeOut: function() {
/**
 * this.oldContainer is the HTMLElement of the old Container
 */

return $(this.oldContainer).animate({ opacity: 0 }).promise();
},

fadeIn: function() {
/**
 * this.newContainer is the HTMLElement of the new Container
 * At this stage newContainer is on the DOM (inside our #barba-
container and with visibility: hidden)
 * Please note, newContainer is available just after
newContainerLoading is resolved!
 */
document.body.scrollTop = 0;
var _this = this;
var $el = $(this.newContainer);

$(this.oldContainer).hide();

$el.css({
  visibility : 'visible',
  opacity : 0
});

initFullpagePlugin($el);

$el.animate({ opacity: 1 }, 400, function() {
  /**
   * Do not forget to call .done() as soon your transition is finished!
   * .done() will automatically remove from the DOM the old Container
   */
  _this.done();
});
}
});

/**
* Next step, you have to tell Barba to use the new Transition
*/

Barba.Pjax.getTransition = function() {
/**
 * Here you can use your own logic!
 * For example you can use different Transition based on the current
 page or link...
 */

 return FadeTransition;
 };
});

$('.no-click').on("click", function(e) {
e.preventDefault();
});

For instance, this design studio has an animation that runs when you first load the home page, but not after a refresh. (NOTE: this seems to only apply to the mobile version, but it's what I'm trying to achieve. The element I'm animating is present on every page, so making sure it only fires on first load & ONLY on the index.html is something I'm shooting for)

Any help/suggestions/constructive criticism is appreciated!

Body:
You can use the transitionCompleted function to load your script.

Barba.Dispatcher.on('transitionCompleted', function(currentStatus, prevStatus) {

    if (prevStatus) {
        setTimeout(function() {

            // call your script

        }, 1000);
    }

});

Remember that the barba.js event transitionCompleted is fired each time a new page is loaded.


问:
Find files older than X days excluding some other files
i'm trying to write a shell script, for linux and solaris, that finds some specific files older than X days and then deletes them. the trick is that during this process there are a couple of files that must not be deleted.

for example from the following list of files i need to delete *.zip and keep *.log and *.something.*

1.zip

2.zip

3.log

prefix.something.suffix

finding the files and feeding them to rm was easy, but i'm having difficulties in excluding the files from the deletion list.

答:
experimenting around i discovered one can benefit from multiple complex expressions grouped with logical operators like this:

```<code>find -L path -type f \( -name '*.log' \) -a ! \( -name '*.zip' -o -name '*something*' \) -mtime +3
</code>```

cheers,

G

Body:
experimenting around i discovered one can benefit from multiple complex expressions grouped with logical operators like this:

find -L path -type f \( -name '*.log' \) -a ! \( -name '*.zip' -o -name '*something*' \) -mtime +3

cheers,

G


问:
How to transitive aar dependencies maven to app
the question as the picture,  app can't invoke the method of library.

答:
already resoved,  the method  is  upload project to maven center  and  use it add transitive =true , example for  (enter code here
compile('com.crashlytics.sdk.android:crashlytics:2.6.7@aar') {
        transitive = true;
    }enter code here
)


问:
Background Image not displaying on iPhone
How do I make the background image display on iPhone as it displays on Android?

HTML

```<code><div class="bgimg-1">
    <div class="hometoptext ">
        <h1 class="text-center">
            Africa's First Online Business Lender
        </h1>
        <div>
            <h3 class="thin">Grow faster with South Africa's most innovative online funder</h3>
        </div>
        <div class="text-center">
            <button class="btn btn-primary" (click)="applyNow()">APPLY NOW</button>
        </div>
    </div>
    <div class="bottom-arrow text-center">

    </div>
</div>
</code>```

Background Image not  displaying on iPhone

CSS

```<code>.bgimg-1 {
    background-image: url("img/main_pic2.png");
    color: white;
    background-position: center center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    background-size: cover;
    -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
    background-color: #999;
    position:relative;
    width:100%;
    min-height: 100vh;
    top: 0;
}
</code>```

Image on Android:

Image on iPhone:

答:
A possible solution to this issue is still a pure CSS Fallback

CSS Tricks has three great methods, the latter two are fall backs for when CSS3's cover doesn't work.

HTML

```<code><img src="img/main_pic2.png" id="bg" alt="">
</code>```

CSS

```<code>#bg {
  position: fixed;
  top: 0;
  left: 0;

  /* Preserve aspect ratio */
  min-width: 100%;
  min-height: 100%;
}
</code>```

Body:
How do I make the background image display on iPhone as it displays on Android?

HTML

            Africa's First Online Business Lender

Grow faster with South Africa's most innovative online funder

            <button class="btn btn-primary" (click)="applyNow()">APPLY NOW</button>

Background Image not  displaying on iPhone

CSS

.bgimg-1 {
    background-image: url("img/main_pic2.png");
    color: white;
    background-position: center center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    background-size: cover;
    -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
    background-color: #999;
    position:relative;
    width:100%;
    min-height: 100vh;
    top: 0;
}

Image on Android:

Image on iPhone:

Body:
A possible solution to this issue is still a pure CSS Fallback

CSS Tricks has three great methods, the latter two are fall backs for when CSS3's cover doesn't work.

HTML

<img src="img/main_pic2.png" id="bg" alt="">

CSS

#bg {
  position: fixed;
  top: 0;
  left: 0;

  /* Preserve aspect ratio */
  min-width: 100%;
  min-height: 100%;
}


问:
How to import CSV file data into a PostgreSQL table
How can I write a stored procedure that imports data from a CSV file and populates the table?</p>

答:
Create a table and have the required columns that are used for creating a table in the CSV file.

Open postgres and right click on the target table which you want to load. Select import and Update the following steps in the file options section

Now browse your file for the filename

Select CSV in format

Encoding as ISO_8859_5

Now go to Misc. options. Check header and click on import.


问:
How to save a Tlistview layout
How do I save a Tlistviews layout in Delphi 2007?

I have been asked to write some code to allow users to re-order columns in a TListview (well all TListviews in our application), I have the code working (by manipulating the columns index and setting width to zero to hide columns not needed) but now I need a way to save the state of the view when to form exits.

What is the best way to do this? I thought about serialization, but I dont need the data or sort order so that seamed a bit overkill to me.

Some things to ponder
     It needs to be on a per user basis
     It needs to be flexible, in-case we add a new column in the middle of the listview
     There is no garantee that the Column headding will be unique
     The listview name may not be unique across the application

Any ideas?

答:
Perhaps the easiest way to store the order of the columns would be to define a ID for each as a meaningfull string, and store the list in the right order in the registry.
For instance, let's suppose your columns were ordered like:

```<code>Name | First name | Age | Job title
</code>```

Then the stored string in the registry could be:

```<code>"Name,FName,Age,JTitle"
</code>```

To be stored in the appropriate registry entry, under the appropriate key (typically HCKU\SOFTWARE\MyApplication, under the key ColumnOrder for instance)

Title: How to save a Tlistview layout

Body:
Perhaps the easiest way to store the order of the columns would be to define a ID for each as a meaningfull string, and store the list in the right order in the registry.
For instance, let's suppose your columns were ordered like:

Name | First name | Age | Job title

Then the stored string in the registry could be:

"Name,FName,Age,JTitle"

To be stored in the appropriate registry entry, under the appropriate key (typically HCKU\SOFTWARE\MyApplication, under the key ColumnOrder for instance)


问:
How to disable/hide JxBrowser License information
I am evaluating JxBrowser API for Java. I realized that the console will print out the license information during run project. Below is the information printed out during java program execution.

```<code>-- Product name: JxBrowser
-- Licensed version: 6.x
-- Licensed to:
-- License type: Evaluation
-- Generation date: Jun 21, 2017
-- Expiration date: Jul 21, 2017
-- License info: Single-user license
-- Current date: Jul 3, 2017
JxBrowser license valid.
</code>```

Is that possible to disable the printing of license information if I will purchase the license in the future?

I tried using:

```<code>System.setProperty("teamdev.license.info", "false");
Browser browser = new Browser();
</code>```

but the console will still print the license information.

答:
In case of using 30-days evaluation license the license information will be always printed into console output. It's true only for the evaluation license.

The license information won't be printed in case of using commercial license. So, when you purchase and use a commercial license, the issue will be solved automatically.

Body:
I am evaluating JxBrowser API for Java. I realized that the console will print out the license information during run project. Below is the information printed out during java program execution.

-- Product name: JxBrowser
-- Licensed version: 6.x
-- Licensed to:
-- License type: Evaluation
-- Generation date: Jun 21, 2017
-- Expiration date: Jul 21, 2017
-- License info: Single-user license
-- Current date: Jul 3, 2017
JxBrowser license valid.

Is that possible to disable the printing of license information if I will purchase the license in the future?

I tried using:

System.setProperty("teamdev.license.info", "false");
Browser browser = new Browser();

but the console will still print the license information.


问:
How to use Angular4 to Codeigniter view?
First, I have PHP Codeigniter project currently run on server

Then I've installed latest Angular4 CLI (Typescript) to server
But I don't know how to integrate with Codeigniter project.

How to use Angular4 in Codeigniter views like an AngularJS?

I guessed, Should I run ng-build every time? for use compiled .js file to PHP view

Any Idea?

答:
Okay, I missed the first line in your question as I answered in the comment, you already have a project written in CodeIgniter and now you want to integrate Angular 4 as a view into this project.

I think you might be able to try it this way, move your CodeIgniter views to Angular views, and since controller->view in CodeIgniter already communicate via JSON, you should be able to turn your CodeIgniter to web service and send back the response as JSON that will be used later by Angular view.

Sorry but I don't know it can be done in another way or not, hope you find the approach soon. (if possible, I hardly recommend you to separate client from the server)


问:
Problem with too many try catch
Is it possible to write a method like outType? TryDo(func, out exception, params) that call func(arg1,arg2,arg3,...) which params contains arg1,arg2,arg3,... and then it return func return value and if any exception occurred return null and set the exception?

Can this be done better by another function signature?

for example I have
string Foo1(int i) { return i.ToString()}

void Foo2(int[] a) {throw new Exception();}

and then call

string t = TryDo(Foo1, out ex, {i});

TryDo(Foo2, out ex, {});

-----------Edited------------------

```<code>        string t;
        SomeClass c;
        try
        {
            t = Foo1(4, 2, new OtherClass());
        }
        catch (Exception ex)
        {
            Log(ex);
            if (/*ex has some features*/)
                throw ex;
        }

        try
        {
            Foo2();
        }
        catch (Exception ex)
        {
            Log(ex);
            if (/*ex has some features*/)
                throw ex;
        }
        .
        .
        .
</code>```

I want to make it like this.

```<code>        string t = TryDo(Foo1, out ex, {4, 2, new OtherClass());
        Examine(ex);
        SomeClass c = TryDo(Foo2, out ex, {});
        Examine(ex);
</code>```

答:
What you are asking indicates that you have misunderstood how exceptions should be handled. Using try/catch everywhere can produce undesired results and make your application a whole lot harder to debug.

In short, only handle exceptions in the following cases:

You can handle the exception and return promised result

Catch layer specific exceptions and replace them with more generic exceptions (SqlException -> DataSourceException)

Catch all is OK in the top layer

Catch all is OK in threads (since uncaught exceptions in threads will crash your app)

More info in my blog: http://blog.gauffin.org/2010/11/do-not-catch-that-exception/

Update

PLEASE do not use throw ex. You are destroying the original call stack and therefore hiding where the exception was thrown originally. throw; is your puppy. Use it everywhere and all the time.

Title: Problem with too many try catch

Body:
Is it possible to write a method like outType? TryDo(func, out exception, params) that call func(arg1,arg2,arg3,...) which params contains arg1,arg2,arg3,... and then it return func return value and if any exception occurred return null and set the exception?

Can this be done better by another function signature?

for example I have
string Foo1(int i) { return i.ToString()}

void Foo2(int[] a) {throw new Exception();}

and then call

string t = TryDo(Foo1, out ex, {i});

TryDo(Foo2, out ex, {});

-----------Edited------------------

        string t;
        SomeClass c;
        try
        {
            t = Foo1(4, 2, new OtherClass());
        }
        catch (Exception ex)
        {
            Log(ex);
            if (/*ex has some features*/)
                throw ex;
        }

        try
        {
            Foo2();
        }
        catch (Exception ex)
        {
            Log(ex);
            if (/*ex has some features*/)
                throw ex;
        }
        .
        .
        .

I want to make it like this.

        string t = TryDo(Foo1, out ex, {4, 2, new OtherClass());
        Examine(ex);
        SomeClass c = TryDo(Foo2, out ex, {});
        Examine(ex);


问:
Filter Log File
I have a Log file which is Log output of Nunit Runner

I want to parse through the file to extract the data;

Here is the sample Log File :

I want to extract the Test Count, Passed and Failed Tests

How to use Regex to get the data.

I am Using Pattern and Scanner Classes to Scan the data.

Here is the sample function i am using to read the file

UPDATE:

I have Used the following Code to extract Test Results, I would like have suggestions on this code:

```<code>  public int FilterLogFile(File LogFile) {
    int TestCount = 0;
    try {

        String Line = "";
        BufferedReader br = new BufferedReader(new FileReader(LogFile));
        while ((Line = br.readLine()) != null) {
            Scanner scanner = new Scanner(Line);
            String line = scanner.findInLine(".*(Test Count:)\\s+\\d+\\D+\\s+.*(Passed:)\\s+\\d+\\D+\\s+.*(Failed:)\\s+\\d+");
            if (line != null) {
                System.out.println("Detected Line: " + line);
                TestCount = ExtractData(Line);
                break;
            } else {
                continue;
            }
        }
    } catch (Exception ex) {
        ex.printStackTrace();
    }

    return TestCount;
}

 private int ExtractData(String strLine) {
    int Count = 0;
    try {

        String[] Data = strLine.split(",");
        for (String str : Data) {
            if (str.contains("Test Count:")) {
                int value = Integer.parseInt(str.replaceAll("[^0-9]", ""));
                Count = value;
                System.out.println(value);
                break;
            }
        }
    } catch (Exception ex) {
        ex.printStackTrace();
    }
    return Count;
}
</code>```

Sample Log I am working on is :

答:
I hope this helpful for you,

use this,

```<code>a = "[test run server,overall result: Failed, Test count:09, Passed: 14, Failed: 1, skipped: 16, start: 1, end: 10, asd: asd,akdsu]"

/Test.+.(?:Failed:.\d+)/
</code>```

Regex: /Test.+.(?:Failed:.\d+)/

Title: Filter Log File

Body:
I have a Log file which is Log output of Nunit Runner

I want to parse through the file to extract the data;

Here is the sample Log File :

I want to extract the Test Count, Passed and Failed Tests

How to use Regex to get the data.

I am Using Pattern and Scanner Classes to Scan the data.

Here is the sample function i am using to read the file

UPDATE:

I have Used the following Code to extract Test Results, I would like have suggestions on this code:

  public int FilterLogFile(File LogFile) {
    int TestCount = 0;
    try {

        String Line = "";
        BufferedReader br = new BufferedReader(new FileReader(LogFile));
        while ((Line = br.readLine()) != null) {
            Scanner scanner = new Scanner(Line);
            String line = scanner.findInLine(".*(Test Count:)\\s+\\d+\\D+\\s+.*(Passed:)\\s+\\d+\\D+\\s+.*(Failed:)\\s+\\d+");
            if (line != null) {
                System.out.println("Detected Line: " + line);
                TestCount = ExtractData(Line);
                break;
            } else {
                continue;
            }
        }
    } catch (Exception ex) {
        ex.printStackTrace();
    }

    return TestCount;
}

 private int ExtractData(String strLine) {
    int Count = 0;
    try {

        String[] Data = strLine.split(",");
        for (String str : Data) {
            if (str.contains("Test Count:")) {
                int value = Integer.parseInt(str.replaceAll("[^0-9]", ""));
                Count = value;
                System.out.println(value);
                break;
            }
        }
    } catch (Exception ex) {
        ex.printStackTrace();
    }
    return Count;
}

Sample Log I am working on is :

Body:
I hope this helpful for you,

use this,

a = "[test run server,overall result: Failed, Test count:09, Passed: 14, Failed: 1, skipped: 16, start: 1, end: 10, asd: asd,akdsu]"

/Test.+.(?:Failed:.\d+)/

Regex: /Test.+.(?:Failed:.\d+)/


问:
What is the difference between Datatable.js and Dynatable.js?
I have around 300,000 data to be showned in table and i used datatable.js but is too much slow as it gathers all the data and paginates it which really annoys. while searching the option i found dynatable.js.
Can Somebody tell me the difference between these two??</p>

答:
There aren't massive differences between the two libraries - I've used both and can say they are pretty much the same thing. Dynatable is more snazzy, with more options for cool front end features, whereas datatables is more rigid. Dynatables allows you to write custom table sorting features (which was a must-have for me).

The most important thing is that dynatable (although it looks cool) still has a lot of bugs, and from what it looks like (last commit to git was in '14), the developer has discontinued the project.


问:
Bind DataTable to Excel spreadsheet directly in C#
I am building a C# VSTO Add-in, and looking for ways to bind System.Data.DataTable directly to Excel spreadsheet (like binding a datasource) and track user modified cells in the spreadsheet and read the changes back in C#.

Thanks for help.

答:
You might want to look at using ListObjects.  You can directly bind an in-memory datatable to a ListObject.  You don't have to display all the fields when you add this listobject (table) to a worksheet.

For example:

```<code>Public WithEvents decideList As Microsoft.Office.Tools.Excel.ListObject
Public dt As System.Data.DataTable = New System.Data.DataTable("MasterData")
' Load data into the datatable dt

Dim worksheet As Microsoft.Office.Tools.Excel.Worksheet = Globals.Factory.GetVstoObject(sheet) 'where sheet is the native worksheet where you are locating the ListObject
Dim cell As Excel.Range = worksheet.Range("$A$1:$D$4")

decideList = worksheet.Controls.AddListObject(cell, "decideList")
decideList.AutoSetDataBoundColumnHeaders = True
decideList.SetDataBinding(dt, Nothing, { "FirstName", "LastName", "Company" })
</code>```

The only problem is persistence.  You will need to save out the the full datatable prior closing the spreadsheet (unless you display the entire datatable in the ListObject).

When you re-open the worksheet, you'll need a method to load the table into an in-memory datatable, the re-bind it.

I hope that helps!

There are a few links online. https://msdn.microsoft.com/en-us/library/cc668212.aspx

The only issues I have had is sometimes its better to update the underlying datatable rather than use the Excel worksheet.  To do this, you can set up events that fire on any changes to the ListObject.

Body:
You might want to look at using ListObjects.  You can directly bind an in-memory datatable to a ListObject.  You don't have to display all the fields when you add this listobject (table) to a worksheet.

For example:

Public WithEvents decideList As Microsoft.Office.Tools.Excel.ListObject
Public dt As System.Data.DataTable = New System.Data.DataTable("MasterData")
' Load data into the datatable dt

Dim worksheet As Microsoft.Office.Tools.Excel.Worksheet = Globals.Factory.GetVstoObject(sheet) 'where sheet is the native worksheet where you are locating the ListObject
Dim cell As Excel.Range = worksheet.Range("$A$1:$D$4")

decideList = worksheet.Controls.AddListObject(cell, "decideList")
decideList.AutoSetDataBoundColumnHeaders = True
decideList.SetDataBinding(dt, Nothing, { "FirstName", "LastName", "Company" })

The only problem is persistence.  You will need to save out the the full datatable prior closing the spreadsheet (unless you display the entire datatable in the ListObject).

When you re-open the worksheet, you'll need a method to load the table into an in-memory datatable, the re-bind it.

I hope that helps!

There are a few links online. https://msdn.microsoft.com/en-us/library/cc668212.aspx

The only issues I have had is sometimes its better to update the underlying datatable rather than use the Excel worksheet.  To do this, you can set up events that fire on any changes to the ListObject.


问:
How to make a background of a button transparent with visible border in Android?
This is the coding of the button. I want to make only borders visible and background of the button should be invisible.But with this code everything is becoming invisible.

```<code><Button
    android:id="@+id/button3"
    android:layout_width="200dp"
    android:layout_height="60dp"
    android:text="Sign In"
    android:textAllCaps="false"
    android:layout_gravity="center"
    android:layout_marginTop="50dp"
    android:textColor="@color/white"
   android:background="@android:color/transparent"
</code>```

I want my button to look like this.

答:
```<code> <Button
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:background="@drawable/button_bg"/>
</code>```

button_bg.xml:

```<code><?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
       android:shape="rectangle">
  <corners
      android:radius="2dp" />
  <stroke
      android:width="2px"
      android:color="@color/your_border_color" />
</shape>
</code>```

Body:
This is the coding of the button. I want to make only borders visible and background of the button should be invisible.But with this code everything is becoming invisible.

<Button
    android:id="@+id/button3"
    android:layout_width="200dp"
    android:layout_height="60dp"
    android:text="Sign In"
    android:textAllCaps="false"
    android:layout_gravity="center"
    android:layout_marginTop="50dp"
    android:textColor="@color/white"
   android:background="@android:color/transparent"

I want my button to look like this.

Body:
 <Button
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:background="@drawable/button_bg"/>

button_bg.xml:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
       android:shape="rectangle">
  <corners
      android:radius="2dp" />
  <stroke
      android:width="2px"
      android:color="@color/your_border_color" />
</shape>


答:
use drawable, create shape.xml

```<code><shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <corners android:radius="1000dp" /> //your radius
    <stroke android:width="3px" android:color="#FFF" /> //your stroke size
</shape>
</code>```

Then implement it in xml

```<code><Button
    android:id="@+id/button3"
    android:layout_width="200dp"
    android:layout_height="60dp"
    android:text="Sign In"
    android:textAllCaps="false"
    android:layout_gravity="center"
    android:layout_marginTop="50dp"
    android:textColor="@color/white"
   android:background="@drawable/shape" />
</code>```

Title: How to make a background of a button transparent with visible border in Android?

Body:
use drawable, create shape.xml

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <corners android:radius="1000dp" /> //your radius
    <stroke android:width="3px" android:color="#FFF" /> //your stroke size
</shape>

Then implement it in xml

<Button
    android:id="@+id/button3"
    android:layout_width="200dp"
    android:layout_height="60dp"
    android:text="Sign In"
    android:textAllCaps="false"
    android:layout_gravity="center"
    android:layout_marginTop="50dp"
    android:textColor="@color/white"
   android:background="@drawable/shape" />


问:
Error creating bean with name 'org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping#0' defined in ServletContext resource
PROBLEM :

I am creating a pointcut for execution of a method in a class . This class is a controller class and denoted by annotation @Controller and hence no bean is needed for the same which is required by the aspect.
I am attaching the dispathcher servlet code , aspect and the controller class.Can somebody identify what the problem is.

DISPATCHER SERVLET :

```<code><?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns:context="http://www.springframework.org/schema/context"
 xmlns:p="http://www.springframework.org/schema/p"
 xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:tx="http://www.springframework.org/schema/tx"
 xsi:schemaLocation="http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
       http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context-3.0.xsd
    http://www.springframework.org/schema/aop
       http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
       http://www.springframework.org/schema/tx
       http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">

 <context:annotation-config />
 <context:spring-configured />

 <aop:aspectj-autoproxy />
  <bean id="LoggerBean" class="com.persistent.eap.aop.LoggerAspect" />

 <bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" >
 <property name="order" value="0" />
 </bean>
 <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" />
 <bean class="com.persistent.eap.validators.UserRegistrationValidator" />

 <bean id="userRegistrationService" class="com.persistent.eap.service.impl.UserRegistrationServiceImpl" />
 <bean id="userOperationsService" class="com.persistent.eap.service.impl.UserOperationsServiceImpl" />

 <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
        <property name="basename" value="messages"/>
    </bean>

 <bean id="tilesViewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
  <property name="viewClass" value="org.springframework.web.servlet.view.tiles2.TilesView"/>
 </bean>
 <bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles2.TilesConfigurer" p:definitions="/WEB-INF/tiles-defs.xml" />

 <context:component-scan base-package="com.persistent.eap.controllers" />
 <context:component-scan base-package="com.persistent.eap.service" />
    <context:component-scan base-package="com.persistent.eap.dao" />

    <import resource="databaseContext.xml"/>

 <bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping" >
  <property name="order" value="1" />
  <property name="mappings">
   <value>
    /*.htm=urlController
            </value>
  </property>
 </bean>

 <bean id="urlController"
  class="org.springframework.web.servlet.mvc.UrlFilenameViewController" />

</beans>
</code>```

ASPECT :

```<code>package com.persistent.eap.aop;

import org.aspectj.lang.ProceedingJoinPoint;

import org.aspectj.lang.annotation.Aspect;

import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Pointcut;
//import org.aspectj.lang.annotation.Before;

@Aspect
public class LoggerAspect {

  @Pointcut("execution(* com.persistent.eap.controllers.UserRegistrationController.setUpForm(..))")
  public void controllerMethods(){}

     @Around("controllerMethods()")
     public Object controllerMethodCall(ProceedingJoinPoint call) throws Throwable{
        System.out.println("[LOGGING INFO : Entering Method "+call.toShortString()+" ]");

     Object point=call.proceed();

     System.out.println("[LOGGING INFO : Exiting Method "+call.toShortString()+" with return as "+point+" ]");
     return point;
     }

}
</code>```

CONTROLLER CLASS :

```<code>package com.persistent.eap.controllers;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.persistent.eap.domain.UserDetails;
import com.persistent.eap.service.intfc.UserRegistrationService;
import com.persistent.eap.validators.UserRegistrationValidator;

@Controller
@RequestMapping("/userRegistrationForm.htm")
public class UserRegistrationController {

 private UserRegistrationService userRegistrationService;
 private UserRegistrationValidator userRegistrationValidator;

 @Autowired
 public UserRegistrationController(UserRegistrationService userRegistrationService
                            ,UserRegistrationValidator userRegistrationValidator) {
  this.userRegistrationService = userRegistrationService;
  this.userRegistrationValidator = userRegistrationValidator;
 }

 @RequestMapping(method=RequestMethod.GET)
 public String setUpForm(ModelMap model){
  UserDetails userDetails = new UserDetails();
  model.addAttribute("userDetails", userDetails);
  return "userRegistrationForm";
 }

 @RequestMapping(method=RequestMethod.POST)
 public String onSubmit(@ModelAttribute("userDetails") UserDetails userDetails,BindingResult result){
  userRegistrationValidator.validate(userDetails, result);
  if(result.hasErrors()){
   return "userRegistrationForm";
  }
  else{
   System.out.println(userDetails.getId()+"  "+userDetails.getUsername());
   userRegistrationService.registerUserDetails(userDetails);
   return "userRegistrationSuccess";
  }
 }

}
</code>```

ERROR ON CONSOLE :

```<code>SEVERE: StandardWrapper.Throwable
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping#0' defined in ServletContext resource [/WEB-INF/dispatcher-servlet.xml]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userRegistrationController' defined in file [C:\Documents and Settings\samiksha_kalra\Desktop\VMforce\EclipseWorkspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\EAPProject\WEB-INF\classes\com\persistent\eap\controllers\UserRegistrationController.class]: Initialization of bean failed; nested exception is org.springframework.aop.framework.AopConfigException: Could not generate CGLIB subclass of class [class com.persistent.eap.controllers.UserRegistrationController]: Common causes of this problem include using a final class or a non-visible class; nested exception is java.lang.IllegalArgumentException: Superclass has no null constructors but no arguments were given
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
 at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
 at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
 at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
 at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
 at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580)
 at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
 at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
 at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:442)
 at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:458)
 at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:339)
 at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:306)
 at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:127)
 at javax.servlet.GenericServlet.init(GenericServlet.java:212)
 at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1173)
 at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:993)
 at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4350)
 at org.apache.catalina.core.StandardContext.start(StandardContext.java:4659)
 at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
 at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
 at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
 at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:445)
 at org.apache.catalina.core.StandardService.start(StandardService.java:519)
 at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
 at org.apache.catalina.startup.Catalina.start(Catalina.java:581)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
 at java.lang.reflect.Method.invoke(Unknown Source)
 at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
 at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userRegistrationController' defined in file [C:\Documents and Settings\samiksha_kalra\Desktop\VMforce\EclipseWorkspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\EAPProject\WEB-INF\classes\com\persistent\eap\controllers\UserRegistrationController.class]: Initialization of bean failed; nested exception is org.springframework.aop.framework.AopConfigException: Could not generate CGLIB subclass of class [class com.persistent.eap.controllers.UserRegistrationController]: Common causes of this problem include using a final class or a non-visible class; nested exception is java.lang.IllegalArgumentException: Superclass has no null constructors but no arguments were given
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
 at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
 at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
 at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
 at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
 at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1075)
 at org.springframework.web.servlet.handler.AbstractUrlHandlerMapping.registerHandler(AbstractUrlHandlerMapping.java:383)
 at org.springframework.web.servlet.handler.AbstractUrlHandlerMapping.registerHandler(AbstractUrlHandlerMapping.java:362)
 at org.springframework.web.servlet.handler.AbstractDetectingUrlHandlerMapping.detectHandlers(AbstractDetectingUrlHandlerMapping.java:82)
 at org.springframework.web.servlet.handler.AbstractDetectingUrlHandlerMapping.initApplicationContext(AbstractDetectingUrlHandlerMapping.java:58)
 at org.springframework.context.support.ApplicationObjectSupport.initApplicationContext(ApplicationObjectSupport.java:119)
 at org.springframework.web.context.support.WebApplicationObjectSupport.initApplicationContext(WebApplicationObjectSupport.java:72)
 at org.springframework.context.support.ApplicationObjectSupport.setApplicationContext(ApplicationObjectSupport.java:73)
 at org.springframework.context.support.ApplicationContextAwareProcessor.invokeAwareInterfaces(ApplicationContextAwareProcessor.java:106)
 at org.springframework.context.support.ApplicationContextAwareProcessor.postProcessBeforeInitialization(ApplicationContextAwareProcessor.java:85)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:394)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1413)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
 ... 31 more
Caused by: org.springframework.aop.framework.AopConfigException: Could not generate CGLIB subclass of class [class com.persistent.eap.controllers.UserRegistrationController]: Common causes of this problem include using a final class or a non-visible class; nested exception is java.lang.IllegalArgumentException: Superclass has no null constructors but no arguments were given
 at org.springframework.aop.framework.Cglib2AopProxy.getProxy(Cglib2AopProxy.java:212)
 at org.springframework.aop.framework.ProxyFactory.getProxy(ProxyFactory.java:112)
 at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.createProxy(AbstractAutoProxyCreator.java:476)
 at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:362)
 at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:322)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:407)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1426)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
 ... 49 more
Caused by: java.lang.IllegalArgumentException: Superclass has no null constructors but no arguments were given
 at net.sf.cglib.proxy.Enhancer.emitConstructors(Enhancer.java:718)
 at net.sf.cglib.proxy.Enhancer.generateClass(Enhancer.java:499)
 at net.sf.cglib.transform.TransformingClassGenerator.generateClass(TransformingClassGenerator.java:33)
 at net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25)
 at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:216)
 at net.sf.cglib.proxy.Enhancer.createHelper(Enhancer.java:377)
 at net.sf.cglib.proxy.Enhancer.create(Enhancer.java:285)
 at org.springframework.aop.framework.Cglib2AopProxy.getProxy(Cglib2AopProxy.java:200)
 ... 56 more
Dec 20, 2010 6:28:42 PM org.apache.catalina.core.StandardContext loadOnStartup
SEVERE: Servlet /EAPProject threw load() exception
java.lang.IllegalArgumentException: Superclass has no null constructors but no arguments were given
 at net.sf.cglib.proxy.Enhancer.emitConstructors(Enhancer.java:718)
 at net.sf.cglib.proxy.Enhancer.generateClass(Enhancer.java:499)
 at net.sf.cglib.transform.TransformingClassGenerator.generateClass(TransformingClassGenerator.java:33)
 at net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25)
 at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:216)
 at net.sf.cglib.proxy.Enhancer.createHelper(Enhancer.java:377)
 at net.sf.cglib.proxy.Enhancer.create(Enhancer.java:285)
 at org.springframework.aop.framework.Cglib2AopProxy.getProxy(Cglib2AopProxy.java:200)
 at org.springframework.aop.framework.ProxyFactory.getProxy(ProxyFactory.java:112)
 at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.createProxy(AbstractAutoProxyCreator.java:476)
 at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:362)
 at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:322)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:407)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1426)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
 at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
 at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
 at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
 at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
 at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1075)
 at org.springframework.web.servlet.handler.AbstractUrlHandlerMapping.registerHandler(AbstractUrlHandlerMapping.java:383)
 at org.springframework.web.servlet.handler.AbstractUrlHandlerMapping.registerHandler(AbstractUrlHandlerMapping.java:362)
 at org.springframework.web.servlet.handler.AbstractDetectingUrlHandlerMapping.detectHandlers(AbstractDetectingUrlHandlerMapping.java:82)
 at org.springframework.web.servlet.handler.AbstractDetectingUrlHandlerMapping.initApplicationContext(AbstractDetectingUrlHandlerMapping.java:58)
 at org.springframework.context.support.ApplicationObjectSupport.initApplicationContext(ApplicationObjectSupport.java:119)
 at org.springframework.web.context.support.WebApplicationObjectSupport.initApplicationContext(WebApplicationObjectSupport.java:72)
 at org.springframework.context.support.ApplicationObjectSupport.setApplicationContext(ApplicationObjectSupport.java:73)
 at org.springframework.context.support.ApplicationContextAwareProcessor.invokeAwareInterfaces(ApplicationContextAwareProcessor.java:106)
 at org.springframework.context.support.ApplicationContextAwareProcessor.postProcessBeforeInitialization(ApplicationContextAwareProcessor.java:85)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:394)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1413)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
 at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
 at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
 at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
 at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
 at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580)
 at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
 at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
 at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:442)
 at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:458)
 at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:339)
 at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:306)
 at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:127)
 at javax.servlet.GenericServlet.init(GenericServlet.java:212)
 at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1173)
 at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:993)
 at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4350)
 at org.apache.catalina.core.StandardContext.start(StandardContext.java:4659)
 at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
 at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
 at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
 at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:445)
 at org.apache.catalina.core.StandardService.start(StandardService.java:519)
 at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
 at org.apache.catalina.startup.Catalina.start(Catalina.java:581)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
 at java.lang.reflect.Method.invoke(Unknown Source)
 at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
 at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
</code>```

答:
This is a limitation in Spring AOP. When you use AspectJ pointcuts to weave aspects into beans, Spring will use CGLIB to generate a subclass of the target, and invoke the aspects from that subclass.

If the target class does not have a public default constructor, however, this will fail. CGLIB does have the ability to handle this, but this is all hidden behind the Spring AOP stuff and you can't change that behaviour.

I can only suggest that you go back to using setter injection for your controller, rather than constructor injection. It's not ideal, I know, but I can't think of any other workaround.

Body:
PROBLEM :

I am creating a pointcut for execution of a method in a class . This class is a controller class and denoted by annotation @Controller and hence no bean is needed for the same which is required by the aspect.
I am attaching the dispathcher servlet code , aspect and the controller class.Can somebody identify what the problem is.

DISPATCHER SERVLET :

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns:context="http://www.springframework.org/schema/context"
 xmlns:p="http://www.springframework.org/schema/p"
 xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:tx="http://www.springframework.org/schema/tx"
 xsi:schemaLocation="http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
       http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context-3.0.xsd
    http://www.springframework.org/schema/aop
       http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
       http://www.springframework.org/schema/tx
       http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">

 <context:annotation-config />
 <context:spring-configured />

 <aop:aspectj-autoproxy />
  <bean id="LoggerBean" class="com.persistent.eap.aop.LoggerAspect" />

 <bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" >
 <property name="order" value="0" />
 </bean>
 <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" />
 <bean class="com.persistent.eap.validators.UserRegistrationValidator" />

 <bean id="userRegistrationService" class="com.persistent.eap.service.impl.UserRegistrationServiceImpl" />
 <bean id="userOperationsService" class="com.persistent.eap.service.impl.UserOperationsServiceImpl" />

 <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
        <property name="basename" value="messages"/>
    </bean>

 <bean id="tilesViewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
  <property name="viewClass" value="org.springframework.web.servlet.view.tiles2.TilesView"/>
 </bean>
 <bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles2.TilesConfigurer" p:definitions="/WEB-INF/tiles-defs.xml" />

 <context:component-scan base-package="com.persistent.eap.controllers" />
 <context:component-scan base-package="com.persistent.eap.service" />
    <context:component-scan base-package="com.persistent.eap.dao" />

    <import resource="databaseContext.xml"/>

 <bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping" >
  <property name="order" value="1" />
  <property name="mappings">
   <value>
    /*.htm=urlController
            </value>
  </property>
 </bean>

 <bean id="urlController"
  class="org.springframework.web.servlet.mvc.UrlFilenameViewController" />

</beans>

ASPECT :

package com.persistent.eap.aop;

import org.aspectj.lang.ProceedingJoinPoint;

import org.aspectj.lang.annotation.Aspect;

import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Pointcut;
//import org.aspectj.lang.annotation.Before;

@Aspect
public class LoggerAspect {

  @Pointcut("execution(* com.persistent.eap.controllers.UserRegistrationController.setUpForm(..))")
  public void controllerMethods(){}

     @Around("controllerMethods()")
     public Object controllerMethodCall(ProceedingJoinPoint call) throws Throwable{
        System.out.println("[LOGGING INFO : Entering Method "+call.toShortString()+" ]");

     Object point=call.proceed();

     System.out.println("[LOGGING INFO : Exiting Method "+call.toShortString()+" with return as "+point+" ]");
     return point;
     }

}

CONTROLLER CLASS :

package com.persistent.eap.controllers;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.persistent.eap.domain.UserDetails;
import com.persistent.eap.service.intfc.UserRegistrationService;
import com.persistent.eap.validators.UserRegistrationValidator;

@Controller
@RequestMapping("/userRegistrationForm.htm")
public class UserRegistrationController {

 private UserRegistrationService userRegistrationService;
 private UserRegistrationValidator userRegistrationValidator;

 @Autowired
 public UserRegistrationController(UserRegistrationService userRegistrationService
                            ,UserRegistrationValidator userRegistrationValidator) {
  this.userRegistrationService = userRegistrationService;
  this.userRegistrationValidator = userRegistrationValidator;
 }

 @RequestMapping(method=RequestMethod.GET)
 public String setUpForm(ModelMap model){
  UserDetails userDetails = new UserDetails();
  model.addAttribute("userDetails", userDetails);
  return "userRegistrationForm";
 }

 @RequestMapping(method=RequestMethod.POST)
 public String onSubmit(@ModelAttribute("userDetails") UserDetails userDetails,BindingResult result){
  userRegistrationValidator.validate(userDetails, result);
  if(result.hasErrors()){
   return "userRegistrationForm";
  }
  else{
   System.out.println(userDetails.getId()+"  "+userDetails.getUsername());
   userRegistrationService.registerUserDetails(userDetails);
   return "userRegistrationSuccess";
  }
 }

}

ERROR ON CONSOLE :

SEVERE: StandardWrapper.Throwable
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping#0' defined in ServletContext resource [/WEB-INF/dispatcher-servlet.xml]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userRegistrationController' defined in file [C:\Documents and Settings\samiksha_kalra\Desktop\VMforce\EclipseWorkspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\EAPProject\WEB-INF\classes\com\persistent\eap\controllers\UserRegistrationController.class]: Initialization of bean failed; nested exception is org.springframework.aop.framework.AopConfigException: Could not generate CGLIB subclass of class [class com.persistent.eap.controllers.UserRegistrationController]: Common causes of this problem include using a final class or a non-visible class; nested exception is java.lang.IllegalArgumentException: Superclass has no null constructors but no arguments were given
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
 at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
 at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
 at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
 at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
 at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580)
 at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
 at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
 at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:442)
 at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:458)
 at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:339)
 at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:306)
 at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:127)
 at javax.servlet.GenericServlet.init(GenericServlet.java:212)
 at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1173)
 at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:993)
 at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4350)
 at org.apache.catalina.core.StandardContext.start(StandardContext.java:4659)
 at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
 at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
 at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
 at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:445)
 at org.apache.catalina.core.StandardService.start(StandardService.java:519)
 at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
 at org.apache.catalina.startup.Catalina.start(Catalina.java:581)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
 at java.lang.reflect.Method.invoke(Unknown Source)
 at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
 at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userRegistrationController' defined in file [C:\Documents and Settings\samiksha_kalra\Desktop\VMforce\EclipseWorkspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\EAPProject\WEB-INF\classes\com\persistent\eap\controllers\UserRegistrationController.class]: Initialization of bean failed; nested exception is org.springframework.aop.framework.AopConfigException: Could not generate CGLIB subclass of class [class com.persistent.eap.controllers.UserRegistrationController]: Common causes of this problem include using a final class or a non-visible class; nested exception is java.lang.IllegalArgumentException: Superclass has no null constructors but no arguments were given
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
 at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
 at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
 at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
 at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
 at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1075)
 at org.springframework.web.servlet.handler.AbstractUrlHandlerMapping.registerHandler(AbstractUrlHandlerMapping.java:383)
 at org.springframework.web.servlet.handler.AbstractUrlHandlerMapping.registerHandler(AbstractUrlHandlerMapping.java:362)
 at org.springframework.web.servlet.handler.AbstractDetectingUrlHandlerMapping.detectHandlers(AbstractDetectingUrlHandlerMapping.java:82)
 at org.springframework.web.servlet.handler.AbstractDetectingUrlHandlerMapping.initApplicationContext(AbstractDetectingUrlHandlerMapping.java:58)
 at org.springframework.context.support.ApplicationObjectSupport.initApplicationContext(ApplicationObjectSupport.java:119)
 at org.springframework.web.context.support.WebApplicationObjectSupport.initApplicationContext(WebApplicationObjectSupport.java:72)
 at org.springframework.context.support.ApplicationObjectSupport.setApplicationContext(ApplicationObjectSupport.java:73)
 at org.springframework.context.support.ApplicationContextAwareProcessor.invokeAwareInterfaces(ApplicationContextAwareProcessor.java:106)
 at org.springframework.context.support.ApplicationContextAwareProcessor.postProcessBeforeInitialization(ApplicationContextAwareProcessor.java:85)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:394)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1413)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
 ... 31 more
Caused by: org.springframework.aop.framework.AopConfigException: Could not generate CGLIB subclass of class [class com.persistent.eap.controllers.UserRegistrationController]: Common causes of this problem include using a final class or a non-visible class; nested exception is java.lang.IllegalArgumentException: Superclass has no null constructors but no arguments were given
 at org.springframework.aop.framework.Cglib2AopProxy.getProxy(Cglib2AopProxy.java:212)
 at org.springframework.aop.framework.ProxyFactory.getProxy(ProxyFactory.java:112)
 at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.createProxy(AbstractAutoProxyCreator.java:476)
 at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:362)
 at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:322)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:407)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1426)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
 ... 49 more
Caused by: java.lang.IllegalArgumentException: Superclass has no null constructors but no arguments were given
 at net.sf.cglib.proxy.Enhancer.emitConstructors(Enhancer.java:718)
 at net.sf.cglib.proxy.Enhancer.generateClass(Enhancer.java:499)
 at net.sf.cglib.transform.TransformingClassGenerator.generateClass(TransformingClassGenerator.java:33)
 at net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25)
 at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:216)
 at net.sf.cglib.proxy.Enhancer.createHelper(Enhancer.java:377)
 at net.sf.cglib.proxy.Enhancer.create(Enhancer.java:285)
 at org.springframework.aop.framework.Cglib2AopProxy.getProxy(Cglib2AopProxy.java:200)
 ... 56 more
Dec 20, 2010 6:28:42 PM org.apache.catalina.core.StandardContext loadOnStartup
SEVERE: Servlet /EAPProject threw load() exception
java.lang.IllegalArgumentException: Superclass has no null constructors but no arguments were given
 at net.sf.cglib.proxy.Enhancer.emitConstructors(Enhancer.java:718)
 at net.sf.cglib.proxy.Enhancer.generateClass(Enhancer.java:499)
 at net.sf.cglib.transform.TransformingClassGenerator.generateClass(TransformingClassGenerator.java:33)
 at net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25)
 at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:216)
 at net.sf.cglib.proxy.Enhancer.createHelper(Enhancer.java:377)
 at net.sf.cglib.proxy.Enhancer.create(Enhancer.java:285)
 at org.springframework.aop.framework.Cglib2AopProxy.getProxy(Cglib2AopProxy.java:200)
 at org.springframework.aop.framework.ProxyFactory.getProxy(ProxyFactory.java:112)
 at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.createProxy(AbstractAutoProxyCreator.java:476)
 at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:362)
 at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:322)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:407)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1426)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
 at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
 at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
 at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
 at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
 at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1075)
 at org.springframework.web.servlet.handler.AbstractUrlHandlerMapping.registerHandler(AbstractUrlHandlerMapping.java:383)
 at org.springframework.web.servlet.handler.AbstractUrlHandlerMapping.registerHandler(AbstractUrlHandlerMapping.java:362)
 at org.springframework.web.servlet.handler.AbstractDetectingUrlHandlerMapping.detectHandlers(AbstractDetectingUrlHandlerMapping.java:82)
 at org.springframework.web.servlet.handler.AbstractDetectingUrlHandlerMapping.initApplicationContext(AbstractDetectingUrlHandlerMapping.java:58)
 at org.springframework.context.support.ApplicationObjectSupport.initApplicationContext(ApplicationObjectSupport.java:119)
 at org.springframework.web.context.support.WebApplicationObjectSupport.initApplicationContext(WebApplicationObjectSupport.java:72)
 at org.springframework.context.support.ApplicationObjectSupport.setApplicationContext(ApplicationObjectSupport.java:73)
 at org.springframework.context.support.ApplicationContextAwareProcessor.invokeAwareInterfaces(ApplicationContextAwareProcessor.java:106)
 at org.springframework.context.support.ApplicationContextAwareProcessor.postProcessBeforeInitialization(ApplicationContextAwareProcessor.java:85)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:394)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1413)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
 at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
 at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
 at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
 at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
 at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580)
 at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
 at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
 at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:442)
 at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:458)
 at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:339)
 at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:306)
 at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:127)
 at javax.servlet.GenericServlet.init(GenericServlet.java:212)
 at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1173)
 at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:993)
 at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4350)
 at org.apache.catalina.core.StandardContext.start(StandardContext.java:4659)
 at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
 at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
 at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
 at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:445)
 at org.apache.catalina.core.StandardService.start(StandardService.java:519)
 at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
 at org.apache.catalina.startup.Catalina.start(Catalina.java:581)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
 at java.lang.reflect.Method.invoke(Unknown Source)
 at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
 at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)