Annotation @Get does not work in controller

Asked

Viewed 71 times

0

I am trying to customize my url with @Get on Vraptor 4, but it is not recognized,

Follow the controller:

    @Controller
    public class OlaController {
       @Inject Result result;

       @Get("/ola")
       public void digaOla(){
         result.include("mensagem", "Olá, VRaptor 4!");
       }
    }

In the browser appears error 404, but without the annotation the page is displayed normally, there is some library or something I did not import?

Just follow my pom:

 <dependency>
        <groupId>br.com.caelum</groupId>
        <artifactId>vraptor</artifactId>
        <version>4.2.0-RC3</version>
        <type>jar</type>
    </dependency>
    <dependency>
        <groupId>jstl</groupId>
        <artifactId>jstl</artifactId>
        <version>1.2</version>
    </dependency>

    <dependency>
        <groupId>javax.inject</groupId>
        <artifactId>javax.inject</artifactId>
        <version>1</version>
        <scope>provided</scope>
    </dependency>
    <!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-web-api</artifactId>
        <version>7.0</version>
        <scope>provided</scope>
    </dependency>

Follow my web.xml:

<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
 version="3.1">
<session-config>
    <session-timeout>
        30
    </session-timeout>
</session-config>

I’m using the wildfly server.

1 answer

0

To customize your URL in Vraptor you need to define the path in the annotation @Path

Example:

@Get
@Path("/listar")
public void listar() {..}

More explanations about the Path:

Javadoc Vraptor

  • That way you’re not loading the view either.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.