Error http 406 Spring MVC Netbeans

0

I'm using Spring Framework with Netbeans

When I put in the browse localhost / 8080 / xxxx / request I get the error 406

These are my files: 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:p="http://www.springframework.org/schema/p"  
    xmlns:context="http://www.springframework.org/schema/context"  
    xsi:schemaLocation="http://www.springframework.org/schema/beans  
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd  
http://www.springframework.org/schema/context  
http://www.springframework.org/schema/context/spring-context-4.0.xsd">  
    <context:component-scan base-package="com.mycompany.evaluacion_tecnica"/> 


    <bean id="viewResolver"
          class="org.springframework.web.servlet.view.InternalResourceViewResolver"
          p:prefix="/WEB-INF/jsp/"
          p:suffix=".jsp" />    
</beans>

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1" 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">
    <!--<context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/applicationContext.xml</param-value>
    </context-param>
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>-->
    <servlet>
        <servlet-name>dispatcher</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>2</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>dispatcher</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>
    <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>
    <welcome-file-list>
        <welcome-file>redirect.jsp</welcome-file>
    </welcome-file-list>
</web-app>

controller

    import util.MessageConstants;
.....
    import util.ResponseMessage;
    import org.springframework.web.bind.annotation.RestController;
    /**
     *
     * @author Alex
     */
    @RestController
    public class solicitudController {

        @Autowired
        SolicitudService solicitudService ;


         @RequestMapping(value =  "/solicitud", method = RequestMethod.GET )
        public ResponseEntity<ResponseMessage> getSolicitud(HttpServletRequest httpRequest, HttpServletResponse httpServletResponse) throws IOException {
               ResponseMessage response = null;
            try {
                String message = "ok";
                List<SolicitudBean> lstSolicitudBean = solicitudService.getListSolicitud();
                            lstSolicitudBean = null;
                response = new ResponseMessage(MessageConstants.EXITO,message);
                response.setData(lstSolicitudBean);
                            System.out.println("En el try");
                return new ResponseEntity<ResponseMessage>(response, response.getHttpStatus());

            } catch (Exception e) {
                 response = new ResponseMessage(MessageConstants.EXITO, "error");       
                             System.out.println("En el try");
                return new ResponseEntity<ResponseMessage>(response, MessageConstants.EXITO.getHttpStatus());
            }

        }

I do not know what could be wrong, the idea that I have is to return an object that contains the data and that data can work with angularjs to show it in my views.

This is my ResponseMessage class

package useful;
import java.util.List; import org.springframework.http.HttpStatus; // import com.TOPStrategic.dev.util.MessageConstants;

public class ResponseMessage{
    Integer code;
    String message;
    List<String> messageDetail;
    String type;
    Integer valor;
    HttpStatus httpStatus;
    Object data;



    public ResponseMessage(MessageConstants messageConstants, String message ) {
        this.code=messageConstants.idMessage();
        this.message=message;
        this.type=messageConstants.getTypeMessage();
        //2 lineas agregada ....
        this.httpStatus=messageConstants.getHttpStatus();
        this.valor=messageConstants.getHttpStatus().value();
        //this.reason=messageConstants.getHttpStatus().getReasonPhrase();
    }


    public ResponseMessage(MessageConstants messageConstants ) {
        this.code=messageConstants.idMessage();
        this.type=messageConstants.getTypeMessage();
        //this.message = msg.getMessage(messageConstants.codeMessage(),null, objLocale); 
        //2 lineas agregada ....

        this.httpStatus=messageConstants.getHttpStatus();
        this.valor=messageConstants.getHttpStatus().value();
        //this.reason=messageConstants.getHttpStatus().getReasonPhrase();
    }

    public ResponseMessage(MessageConstants messageConstants,List<String> messageDetail, String message ) {
        this.code=messageConstants.idMessage();
        this.message=message;
        this.type=messageConstants.getTypeMessage();
        this.messageDetail = messageDetail;
    }

    public ResponseMessage() { 
    }
    public ResponseMessage(String message) {
        this.message = message;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }
    public Integer getValor() {
        return valor;
    }
    public void setValor(Integer valor) {
        this.valor = valor;
    }


    public Object getData() {
        return data;
    }
    public void setData(Object data) {
        this.data = data;
    }
    public String getType() {
        return type;
    }
    public void setType(String type) {
        this.type = type;
    }
    public Integer getCode() {
        return code;
    }
    public void setCode(Integer code) {
        this.code = code;
    }
    public List<String> getMessageDetail() {
        return messageDetail;
    }
    public void setMessageDetail(List<String> messageDetail) {
        this.messageDetail = messageDetail;
    }


    public HttpStatus getHttpStatus() {
        return httpStatus;
    }


    public void setHttpStatus(HttpStatus httpStatus) {
        this.httpStatus = httpStatus;
    }   


}

this is the structure of my project

Thank you very much for the help ..

    
asked by alex diego 30.12.2018 в 09:45
source

0 answers