Questions tagged [struts2-convention-plugin]

The Struts 2 Convention Plugin provides Struts 2 with convention-based actions and views, allowing zero-config Struts 2 applications, while providing customization at multiple levels.

The Struts 2 Convention Plugin provides Struts 2 with convention-based actions and views, allowing zero-config Struts 2 applications, while providing customization at multiple levels.

Features include:

  • Action location by package naming conventions
  • Result (JSP, FreeMarker, etc) location by naming conventions
  • Class name to URL naming convention
  • Package name to namespace convention
  • SEO compliant URLs (i.e. my-action rather than MyAction)
  • Action name overrides using annotations
  • Interceptor overrides using annotations
  • Namespace overrides using annotations
  • XWork package overrides using annotations
  • Default action and result handling (i.e. /products will try com.example.actions.Products as well as com.example.actions.products.Index)

This plugin can provide additional configuration based on convention. It also uses annotations to replace or override the configuration settings made by this plugin. All annotations that could be used in the code you can find under the package org.apache.struts2.convention.annotation.

80 questions
6
votes
1 answer

Should struts annotation @Result only be in class level or not?

I am reading Struts2 documentation and found that there was kind of contradiction in its documentation. In this link https://struts.apache.org/docs/convention-plugin.html The Convention plugin allows action classes to define different results for…
5
votes
2 answers

Struts2 Annotated or XML based ? which is more easier to manage and uncomplicated?

Which is the easier and organized way to use Struts2 ? With Annotations or with XML files ? If with annotations, then with which kind of annotations? With struts-convention-plugin you can even avoid completely writing conventions i.e@results or…
Asadullah Ali
  • 1,056
  • 14
  • 31
4
votes
2 answers

Reusing Custom Expression Validator in Struts 2

In Struts 2 we can develop @CustomValidator which can be used in application wide @CustomValidator(type = "CustomerNumberValidator", fieldName = "customerNo") For validation more than one field we use…
4
votes
1 answer

struts2 conventions plugin not working properly

I was trying to run the application with convention plugin Struts2. The application was fine with struts.xml configured like this:
3
votes
2 answers

Startup Error: java.lang.IncompatibleClassChangeError: org/apache/struts2/convention/DefaultClassFinder$InfoBuildingVisitor

I have a Struts2 application, originally XML-based, but now for the first time I introduced an Annotation-based action, and the application broke on startup. Given the following Action mapping, on startup of the application, I get the…
gene b.
  • 10,512
  • 21
  • 115
  • 227
3
votes
2 answers

My action class is being mapped without Struts.xml mappins or java annotations

I have a JSP login page that would call the login action class. I was using Struts annotations rather than the struts.xml to the mapping and everything was working fine. I was randomly trying something new so I removed all the annotations from my…
3
votes
1 answer

Deny direct access to JSP files in Struts2 with Naming Convention plugin

I've been struggling with this issue as I'm new to Struts2 development, and just started using this naming Convention Plugin recently. I'm trying to create a simple webapp which at first will only consist in two pages: Login page (login.jsp) Home…
JorgeGRC
  • 1,032
  • 2
  • 18
  • 37
3
votes
1 answer

Multi action in struts form

I want to add 3 button into struts form. My code is : @Action("/admin/product/insert") public String insert() throws Exception { if(upload.hasFile()){ model.setImage(upload.getFileFileName()); …
3
votes
1 answer

How to use Struts2 convention without using any action class

In Struts2 we can define action without using action class in struts.xml as follows: /error.jsp In my application I am using struts2 convention. In this case how to avoid writing action classes.…
user995656
  • 123
  • 1
  • 14
3
votes
1 answer

How to define interceptors using annotations in Struts 2

I'm trying to use the struts2-convention-plugin which provides Java annotations to define Struts2 components. With Actions so far so good but how can I use annotations to define interceptors ? (I'm talking of @InterceptorRefs or @InterceptorRef). Is…
Medioman92
  • 581
  • 4
  • 10
  • 21
3
votes
1 answer

Struts 2 Convention Plugin and JSP files under WEB-INF

When using Struts2 convention plugin, the plugin automatically forwards a hello-world.action request to /WEB-INF/content/hello-world.jsp even if no HelloWorld.java is defined. Please see…
Alireza Fattahi
  • 42,517
  • 14
  • 123
  • 173
3
votes
1 answer

struts2-rest plugin..making both struts actions + rest actions work together but. giving java.lang.reflect.InvocationTargetException

I am converting my existing struts 2 application to serve through some rest based services also. I have used two plugins, struts2-rest plugin and struts-convention plugin, Along with these I have also used asm.jar because above was giving a class…
Piyush_Dev
  • 61
  • 1
  • 7
3
votes
1 answer

How set base package to scan subpackages for actions?

How can I tell to Struts 2 convention plugin to scan all subpackages of a package. I tried with this
user2100029
3
votes
1 answer

Should / Can I make Struts 2 conventions to forget about an action's execute() method?

I am doing my first steps with Struts 2 and the struts2-convention-plugin, currently working on a CRUD action class (SongCrudAction) with some typical create(), edit(), view() and delete() action methods. All those methods are annotated with…
user1992821
  • 268
  • 2
  • 6
3
votes
1 answer

Struts2 token interceptor in annotation

I'm using struts 2.3.1 with token interceptor.How can i use token interceptor in annotation(convension) based Action Class. here is My struts.xml
edaklij
  • 4,121
  • 11
  • 31
  • 43
1
2 3 4 5 6