FAQ Database Discussion Community


Spring Webservices gives 406 error

java,spring,web-services,spring-mvc
I have created a simple Spring with webservices example but when I try to get the response I am getting error as : HTTP Status 406 - The resource identified by this request is only capable of generating responses with characteristics not acceptable according to the request "accept" headers. This...

Adding external static files (css, js, png …) in spring boot

java,spring,spring-mvc,spring-boot,thymeleaf
Background I have a spring boot application which has the logo.png file added to the static folder of the resource file, which is eventually built into the jar file which is used in the execution. This jar application need to be run in multiple instances for different clients. So what...

Spring MVC : Preventing Exceptions when binding model attribute

java,spring,spring-mvc,xss
In my model(s) I use Numeric data types like Long, Integer etc. When I do form post of them, but supply String, it outputs Exception stack trace, including like NumberFormatException. How can i properly wrap this so that UI does not see the exception stack trace ?

Why is my Set variable throwing error when doing a many-many query?

java,spring,hibernate,jsp,spring-mvc
I am new to spring and hibernate. I have created a spring-mvc app with hibernate integration and when I run the code I get the below error. My requirement is to pick the relevant path from the advertisement given the customer category. This involves two tables respectively along with the...

Multiple Controllers appropriate with one entity in spring framework

spring,spring-mvc
I'm starting to develop website that use the spring framework.I have three controller.There are newCustomerController,editCustomerController and deleteCustomerController.These controllers are mapped with view that use for create update and delete, but I create only customer. So, I would like to know.Is it appropriate to declare the controllers like this. Thank ...

Issues with mapping multiple controllers

java,spring,spring-mvc
I am new to spring.My mappings not working correctly though my Tomcat logs show that my URL is mapped. INFO: Mapped URL path [/movie/{name}] onto handler 'movieController' Jun 21, 2015 9:03:24 PM org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler INFO: Mapped URL path [/movie/{name}.*] onto handler 'movieController' Jun 21, 2015 9:03:24 PM org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler INFO:...

GenericApplicationContext cannot be cast to WebApplicationContext : Spring Web Flow

java,spring,spring-mvc,classcastexception,spring-webflow-2
I'm trying to set up Spring Web Flow using only Java annotations in a Spring environment that also uses only Java annotations. However when I attempt to access my flow I get the following exception SEVERE: Servlet.service() for servlet [dispatcher] in context with path [/forms] threw exception [Request processing failed;...

Spring security throws javax.servlet.ServletException: Could not resolve view with name 'j_spring_security_check'

java,spring,spring-mvc,spring-security,tiles-3
I am trying to add Spring security with customized login page and access to database to my Spring MVC application. It seems like my mapping is wrong as it can not map j_spring_security_check. To solve the issue I had a look at following pages 1,2,3 but could not solve the...

i am passing a model class object but it print ad normal object

hibernate,spring-mvc,jstl
i am passing hibernate model class object type list but it prints as [Ljava.lang.Object;@1ec3adc.i am using spring mvc and tile hibernate.i want to pass "Subtab" type list.but it's passing "object" type list. here's the code for returning the list : DAOImpl : public List<Subtab> listSubtab(int usertype){ List<Subtab> subtablist=sessionFactory.getCurrentSession().createQuery("SELECT s.maintab, s.description,...

HTTP Status 500 - Request processing failed;

spring-mvc,thymeleaf
This is my model of consent @Entity @Table(name = "consents") public class Consent extends BaseEntity { /** */ @OneToOne @JoinColumn(name = "provider_id") private Provider provider; @OneToOne @JoinColumn(name = "user_id") private User user; @OneToOne @JoinColumn(name = "friend_id") private User friend; @OneToOne @JoinColumn(name = "document_id") private Document document; @Column(name = "status") private...

How can I test my Struts 1.2 web application without server?

java,unit-testing,spring-mvc,struts-1
I have a Struts 1.2 web application. It has service & DAO classes as well. How can I test each and every layer without any Web/Application server. I heard, Spring provides the same facility for Spring MVC application. How I can test my application end to end? Please suggest?

Spring MVC 2.5 Command object value is changed on form submit

spring-mvc,override,form-submit,command-objects
I have a string variable in command object which is a hidden tag in my jsp. An on click of a button i'm setting this variable with a value(example "test") and submitting the form. On form submit, I get the control to my Validator.validate() method. In this method the value...

Spring: Why is afterPropertiesSet() of InitializingBean needed when there are static and non-static initializers in Java?

java,spring,spring-mvc
I have used afterPropertiesSet() to initialize class properties in Spring beans. Now I see that this task can be accomplished by Java's built in static and non-static initializers. What can I do with afterPropertiesSet() that I cannot with the initializer blocks?

Dyanamic web module 3.0 required java 1.6 or newer

java,maven,spring-mvc
In my project i got following error in Markers. I also set java 1.6 in project facets ,java compliler and buildpath but not solve this error. ...

Spring service and Spring web app in one

spring,web-services,rest,spring-mvc,web
I'm making a Spring RESTFUL service and i wonder. Can I make a Spring RESTFUL service combine with a web app in a project. If it is possible, how to configure it? ....

how to custom spring-security authentication process with my own mechanism

java,spring,security,spring-mvc,spring-security
I'm trying to secure my app with spring security. My understanding about spring security is that they check the loaded password from UserDetails against the password user entered. The thing is my login authentication is inputing username and password into a pl/sql function which will return a result code. So...

Spring MVC Validation error

java,spring,spring-mvc,java-ee
I have a Spring controller that accepts one of my business objects as an argument, that spring is automatically building from form data. One of the attributes of the object is an enum that comes from a select dropdown in the form. I am also using the @Valid notation to...

Logging all network traffic in Spring mvc

java,spring,spring-mvc,logging,slf4j
I have spring mvc application using RequestBody and ResponseBody annotations. They are configured with MappingJackson2HttpMessageConverter. I also have slf4j set up. I would like to log all json as it comes in and out from my controller. I did extend MappingJackson2HttpMessageConverter @Override public Object read(Type type, Class<?> contextClass, HttpInputMessage inputMessage)...

Spring Resttemplate login fails

java,spring,spring-mvc,spring-security,csrf
after an update to spring-4.1.6 i'am not able to login to my rest services any more. I looked on different sides, but couldn't solve the problem... so i ask for help. Here is my my web.xml: <?xml version="1.0" encoding="ISO-8859-1"?> <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5"> <!-- The definition of the...

Jsp list output [email protected]?

jsp,spring-mvc,spring-boot
I have a list of tweets inside a user and when I iterate through them all I get is the object but not the actual text <c:forEach items = "${tweets}" var="user" ></c:forEach> <h1><c:out value="${user.tweets}" /></h1> </div> how do I get the value of the tweets, they all save as text...

FileInputStream in Spring MVC fails to find file

java,spring,spring-mvc
I am working on a SpringMVC project which runs a number of automated tests on a database. The access details for this database are located in a .properties file. This file is located within the project directory. FileInputStream fis = new FileInputStream("batch-dm.properties"); propFile = new Properties(); propFile.load(fis); As the file...

android json data to spring mvc4

java,android,json,spring-mvc,annotations
I am new to using Spring mvc4 annotation . In all i want to do is using spring mvc as a web service . so i would be thankful if anyone could provide me a solution for it. My android code is as: HttpParams httpParams = new BasicHttpParams(); HttpConnectionParams.setConnectionTimeout(httpParams, 5000);...

Form submit portlet with Spring MVC

java,jsp,spring-mvc,liferay,portlet
I'm trying to achieve a Liferay portlet of submit form using spring MVC. The model: package com.model; public class Person { String firstName; String middleName; public String getFirstName() { return this.firstName; } public String getMiddleName() { return this.middleName; } public void setFirstName(String firstName) { this.firstName=firstName; } public void setMiddleName(String middleName)...

Input type text not taking values even after making it editable

javascript,html,spring-mvc
Hi i have a requirement where i will be editing the fields when i click on a edit link.Initially the fields will be under disabled and readonly state.Oncei click on edit the value should be blank and editable. My problem here is the value is changed to blank and i...

How can I retrieve all the values from a particular column in amazon DynamoDB?

java,spring-mvc,amazon-web-services,amazon-dynamodb
For example, if my Question table has columns question_id, options,timestamp, I must retrieve all the values of only 'question_id'. Is it possible?...

spring data mongodb find by collection

mongodb,spring-mvc,annotations,spring-data-mongodb
I am using spring-data-mongodb. Here is my controller method: Controller: @RequestMapping(value = "/getByCategory",method = RequestMethod.GET, consumes=MediaType.APPLICATION_JSON, produces=MediaType.APPLICATION_JSON) public Iterable<Node> getByCategory(@RequestParam(value="categories") List<String> categories) throws EntityNotFoundException { Iterable<Node> nodes = nodeService.getByCategory(categories); return nodes; } Here I am passing list of string as a request parameter. My service method is: public Iterable<Node>...

multiple antMatcher in spring security

spring,spring-mvc,spring-security
I work on content management system, that has three antmatcher like the following http.authorizeRequests() .antMatchers("/", "/*.html").permitAll() .antMatchers("/user/**").hasRole("USER") .antMatchers("/admin/**").hasRole("ADMIN") .antMatchers("/admin/login").permitAll() .antMatchers("/user/login").permitAll() .anyRequest().authenticated() .and() .csrf().disable(); which mean the visitors can see all site at root path (/*), and users can see only (/user), admin can see only (/admin), and there are two...

Intercept @RequestBody after serialization but before controller

spring-mvc
My request body objects all implement a interface call Auditable, where the username and lastUpdate timestamp could be set. I would like to intercept calls to controller functions after serialization but before it hits controller so can I can these values in a single place. I looked at HandlerInterceptor.prehandle but...

spring mvc and tile integration error

java,maven,spring-mvc,tiles
I got an error message when running the tile and spring MVC integrated project. I use spring 3.1.1 and tile 2.2.2.i appreciate your valuable answers error is as follows : java.lang.NoClassDefFoundError: org/apache/tiles/startup/BasicTilesInitializer at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:620) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124) at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2904) at...

the array list from database is not displaying on browser but i can see it on the eclipse console

spring-mvc,thymeleaf
this is my controller @RequestMapping(value = "/users/{userId}/providers/{providerId}/check", method = RequestMethod.GET) public String initNewDocumentForm121(@PathVariable("userId") int userId,@PathVariable("providerId") int providerId, Model model) { List<JdbcDocument> documents = this.clinicService.findByProviderIdAndUserId(providerId, userId); System.out.print("findByProviderIdAndUserId"); System.out.print(documents); return "users/myproviders"; } I can see documents array on the eclipse console but not on browser. <select...

HTTP Status 500 - Request processing failed;

spring-mvc
This is my HTML form. <form th:object="${consent}" action="../users/userDetails.html" th:action="@{${#httpServletRequest.servletPath}}" method="post"> <fieldset> <div class="col-sm-7 col-md-6 col-lg-5"> <label for="last_name">Service Provider</label> <select id="provider" name="provider" class="form-control" th:onchange="'javascript:showPIIDoc(this.value);'"> <option th:value="0" >Select a Service Provider</option> <option id="provider_id" th:each="provider : ${user.providers}"...

Bean Creation exception, Injection of autowired dependency failed

java,spring,hibernate,spring-mvc
I'm using spring hibernate in my application. I used all the required jar files but still getting bean creation exception saying the following: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'voteController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.mindtree.service.VoteService com.mindtree.controller.VoteController.voteService; nested exception is...

Ambiguous mapping found when I use extends clause

java,spring-mvc,inheritance,annotations
I have a CustomerController and CustomerCardController classes that extend CrudMethods class. I choose so, because these two controller use the same methods (getFileCustomer() is one of these). And I thought that it had been better use the inheritance to save code's rows. CustomerController @Controller public class CustomerController extends CrudMethods {...

Spring framework unable to start embedded container

java,spring,maven,spring-mvc,spring-boot
I'm following Spring in Action 4th Edition Chapter 5, but I'm stuck at the very first example. Here is my Eclipse Luna project structure: If I run this project as Spring Boot App, then it throws exceptions: org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.context.ApplicationContextException: Unable to start...

Sending text file to client through Spring MVC web application

java,spring,jsp,spring-mvc,servlets
After doing some research online on the subject I currently managed to get things working with this code: @RequestMapping(value = "/report040Generated", method = RequestMethod.GET) public String index(Model model, HttpServletResponse response, HttpServletRequest request) throws IOException { String myString = "Hello"; response.setContentType("text/plain"); response.setHeader("Content-Disposition","attachment;filename=myFile.txt"); ServletOutputStream out = response.getOutputStream(); out.println(myString); out.flush(); out.close(); return...

unable to pass two lits to the jsp using apachi tiles

hibernate,jsp,spring-mvc,tiles
i am using spring mvc with Apache tile and hibernate.i pass tow lists to the jsp page.but it is print by but there's no any thing prints. my controller class as follows : if(userExists!=0){ model.addAttribute("Maintabs",new Maintab()); model.addAttribute("MaintabsList",loginService.listMaintabs()); model.addAttribute("Subtabs",new Subtab()); model.addAttribute("SubtabsList",loginService.listSubtab(userExists)); return "redirect:/Loginsucess"; }else{ model.addAttribute("error", "ERROR : invaliduser !,Please Try Again!");...

Spring MVC and Ajax error 406

ajax,spring,spring-mvc
I'm trying to run an ajax method with spring MVC, but I'm getting the error 406: "The resource identified by this request is only capable of generating responses with characteristics not acceptable According to the request" accept "headers" Controller: @Transactional @Controller("user") @SessionAttributes("user") public class HomeController { @Autowired private UserDAO daoUser;...

spring dynamic views of different directories

java,spring,spring-mvc
this is my first post in stackoverflow and also i'm new to spring. this is my question(please don't mind my language) this is my folder structure of the project in netbeans(i cant post images yet because i have no 10 reputations) WEB-INF views sales sales_invoice.jsp sales_order.jsp sales_order_list.jsp sales_invoice_list.jsp purchase purchase_order.jsp...

Job not executing at fixed rate

spring-mvc,jobs,execution
I have the following spring mvc configuration: <task:scheduled-tasks scheduler="defaultScheduler"> <task:scheduled ref="myTaskWorker" method="someMethod" fixed-rate="500" /> </task:scheduled-tasks> When I execute the above it is not executed in every 500ms but only executed after the finishing of the previous one. How can i resolve this?...

JSON data binding in spring mvc

java,json,spring-mvc,data-binding
I have received json data from android application in my Spring MVC controller using following code . import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RequestHeader; @RequestMapping(method = RequestMethod.POST, produces = "application/json") public @ResponseBody String getMethod(@RequestHeader(value="json") String headerStr) { System.out.println("POST"); System.out.println(headerStr); return "hello"; } The output of...

Spring MVC - How to return simple String as JSON in Rest Controller

java,json,spring,rest,spring-mvc
My question is essentially a follow-up to this question. @RestController public class TestController { @RequestMapping("/getString") public String getString() { return "Hello World"; } } In the above, Spring would add "Hello World" into the response body. How can I return a String as a JSON response? I understand that I...

Spring, Java : Passing Generic object List as return type

java,spring,spring-mvc,generics,casting
I am working on a Spring-MVC application in which depending upon the mode set by the user, I have to return a List of either Object1 or Object2. Ideally, I can create two controller methods and send the List appropriately, but I would like to know is there any way,...

Mybatis skipping update the specific column if its parameter is null

spring-mvc,mybatis
I HAVE A FOLLOWING UPDATE QUERY IN A MAPPER <update id="updTest" parameterType="TestDTO"> <![CDATA[ UPDATE TEST_USER SET EMAIL = #{email, jdbcType=VARCHAR} , USERNAME = #{username, jdbcType=VARCHAR} , PASSWORD = #{password, jdbcType=VARCHAR} , DOMAIN = #{domain, jdbcType=VARCHAR} , COMPANY = #{company, jdbcType=VARCHAR} , DEPARTMENT = #{department, jdbcType=VARCHAR} , JOBTITLE = #{jobtitle, jdbcType=VARCHAR}...

Remove prefix and suffix of page url in spring MVC

java,spring,jsp,spring-mvc
I created controller using spring mvc: @Controller public class MyController { @RequestMapping("/") public String showHome() { return “/WEB-INF/pages/home.jsp"; } @RequestMapping(“/users") public String showUser() { return "/WEB-INF/pages/users.jsp"; } } I want to avoid writing this /WEB-INF/pages in each method and controller, is there any way to write only the name of...

Spring MVC point to host name

java,maven,spring-mvc,tomcat8
I'm setting up a Spring MVC project for my own knowledge and I'm hitting a bit of a bump. I have a welcome file and a web service set up and they work pretty nicely. However, instead of localhost:8080/ZFGC/ hitting the welcome file, I'd like localhost:8080/ to hit it. From...

Bean property xxxDAO is not writable or has an invalid setter method

java,xml,spring,hibernate,spring-mvc
I know this question has been asked many times. But I could not find my solution. I am using spring with hibernate. There is a connection between User and UserWord as one to many mapping I have done same logic for other models and everything went OK. However when I...

Multipart file upload with OkHttp + Spring

android,spring,spring-mvc,okhttp
I recently switched to OkHttp. After the switch, the code below does the upload. RequestBody requestBody = new MultipartBuilder() .type(MultipartBuilder.FORM) .addPart( Headers.of("Content-Disposition", "form-data; name=\"qqfile\""), RequestBody.create( MediaType.parse(filename), new File(filename))) .build(); If you compare images, the second image has multipartFiles size = 0. It should be of size = 1. How to...

Use thymeleaf template for some pages and rest for some for building gradle project

rest,spring-mvc,gradle,spring-security,thymeleaf
I am new to this please someone tell me whether I can use Thymeleaf template for some pages and REST for some for building Gradle project? I created my login page retrieving through MySQL database using Thymeleaf template now for adding other information in my database I want to use...

Spring Security login with UserDetailsService and Java config

java,spring,spring-mvc,spring-security
I am trying to add login functionality with a database lookup with Spring Security, and I am really struggling. I want to look up the user by implementing the UserDetailsService interface. I have read a ton of documentation and Googled for hours, but I am still stuck. Most of the...

MultipartResolver and AbstractAnnotationConfigDispatcherServletInitializer

java,spring,spring-mvc
I'm having trouble using CommonsMultipartResolver bean in conjunction with an initializer that extends AbstractAnnotationConfigDispatcherServletInitializer. I have successfully used CommonsMultipartResolver in a previous project, but the initializer implements WebApplicationInitializer. Intuitively, I did this in the initializer extending AbstractAnnotationConfigDispatcherServletInitializer. @Override protected Class<?>[] getRootConfigClasses() { return new Class<?>[]{ MultipartUploadConfig.class }; } @Override protected...

How to set HttpServletResponse on Jboss EAP 6.2?

java,spring-mvc,jboss
I have a simple method where I need to change the contentType to "text/plain" but when I am using Jboss EAP 6.2 it is ignored and the returned value is "application/json. @RestController @RequestMapping("/upload") public class UploadController { ... @RequestMapping(method = RequestMethod.POST) public Result foo(MultipartFile arquivo, HttpServletResponse response) { response.setContentType("text/plain"); return...

Importing Spring MVC Project Manually to Eclipse

java,eclipse,spring,spring-mvc
I have a little problem. I had googled for this problem and I haven't found any solution related. My problem is, my office internet using proxy that banned me to download zip file. I need Spring MVC Project template in Spring Tool Suite (STS). So I downloaded the zip file...

GSP in plain Spring MVC - AST Transformation is not applied to taglib

spring-mvc,grails,gsp
I am trying to run GSP views in simple Spring MVC application (without Spring Boot). I am trying to duplicate the example located here: https://github.com/grails/grails-boot/tree/master/sample-apps/gsp but I am trying to run it in plain Spring MVC environment. I have successfully reached the phase when GSP pages are rendered, some g:...

Is it possible to login from a winforms application to a website which uses spring security?

java,c#,winforms,spring-mvc,spring-security
I want to call a web service from my winforms application. My application is written on c# and the webservice is secured using spring security. Is it possible to login to the website and call that web service?. If it is possible how to do that?...

How to deploy a spring boot MVC application in traditional tomcat webapps folder?

java,spring-mvc,tomcat,spring-boot
I created a simple spring mvc application following a springboot springmvc with gradle example. Below is the structure. src/main/java - This is where all the code base is there. src/main/resources - This is where all the resources/templates are there. import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class Application { public static...

Submitting a Form with Angular JS and Spring MVC

java,angularjs,spring-mvc
I am noob with Angular JS and I am having difficulties to submit a simple Form using Angular JS and Spring MVC. I am getting this error: The requested resource is not available mock.jsp <[email protected] prefix='c' uri='http://java.sun.com/jsp/jstl/core'%> <[email protected] prefix="spring" uri="http://www.springframework.org/tags"%> <[email protected] prefix="form" uri="http://www.springframework.org/tags/form"%> <[email protected] prefix="security"uri="http://www.springframework.org/security/tags" %> <!doctype html> <html> <head>...

Apache tomcat issue with Eclipse dynamic web module 3.0

java,spring-mvc,tomcat7
I created Spring MVC project with default configurations it was working/running on the server but when I changed Project Facets to J2EE 6 as following : now when I run the project I get following message UPDATE Please see this project structure : Controller.java is @Controller public class HomeController {...

Spring Mobile apps to be deployed in emulator

javascript,android,html5,spring,spring-mvc
I'm trying to develop an application based on Spring MVC for mobile device. Spring Mobile do provide such features to view our application in mobile browser. But how can I run/deploy the application in emulator since it's non-android based application? Also if can anybody tell me, how can I test...

How to check JAVA variable ${account} in jsp?

java,spring-mvc
I have a dropdown-menu, and I want to check if ${uaccount} equals admin show users_info item I don't konw how to write this in jsp . Please guide me <ul class="dropdown-menu dropdown-user"> <%if(${uaccount}).equals('admin')){ %> <li><a href="users_info">user info</a></li> <%} %> <li><a href="${pageContext.request.contextPath}/logout">logout</a></li> </ul> ...

Spring Boot MVC non-role based security

java,security,spring-mvc,spring-boot
I am attempting to setup security in a new Spring Boot MVC application. I am attempting to do this with no XML configuration, only Java. Currently I have been able to get role based security working using the @Secured annotation on each of my @RequestMapping methods. I also need to...

Send Mail using Spring MVC

spring,spring-mvc,spring-integration
I have a custom MailDto object in which I set the to,cc, bCc field and send it using RestTemplate to Spring MVC controller as below @RequestMapping(value = "/SendMail" ) public ResponseEntity<String> SendMail( @RequestBody MailMessageDto mailDto) throws NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException From the controller I invoke the Gateway (Spring integration). The...

Hibernate : Stale state exception

java,spring,hibernate,spring-mvc,transactions
I am working on a Spring-MVC application in which I am trying to delete an object from the database. Some days back, this error all of a sudden started, and now I am unable to delete. I checked on net, but I cannot find what am I doing wrong and...

Spring MVC link with .jsp/.jsp suffix returns 404

java,spring,jsp,spring-mvc
I have a simple page called headers.jsp in my Spring-MVC (4.1.5.RELEASE) web-app which i would like to call up from my index page like this: <body> <c:url value="/headers" var="headersUrl1"/> <c:url value="/headers.jsp" var="headersUrl2"/> <c:url value="/headers.jspx" var="headersUrl3"/> <ul> <li><a href="${headersUrl1}">Works!</a></li> <li><a href="${headersUrl2}">Does not work!</a></li> <li><a href="${headersUrl3}">Does not...

viewResolver with more folders inside of WEB-INF/jsp is not working in spring

java,spring,jsp,spring-mvc
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="viewClass" value="org.springframework.web.servlet.view.JstlView" /> <!-- avoid '???' --> <property name="prefix" value="/WEB-INF/jsp/" /> <property name="suffix" value=".jsp"/> </bean> if i create other subfolders under jsp , for instance /WEB-INF/jsp/reports , /WEB-INF/jsp/insertions how should i configure now the viewResolver to can resolve these new sub folders??...

Spring Boot not displaying web contents

spring,spring-mvc,spring-security,spring-boot
I have a Spring Boot Application used as a secured REST API backend. I would like to have some static page with the documentation about that API (I'd like to use a Wiki, for instance) As far as I try I cannot make it display static contents: e.g. I tried...

Cannot marshall type class without a custom marshaler or @DynamoDBDocument annotation

java,spring-mvc,amazon-web-services,amazon-dynamodb,spring-restcontroller
Error: com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMappingException: Cannot marshall type class [Ljava.lang.String; without a custom marshaler or @DynamoDBDocument annotation. I want to store data to DynamoDB from java Spring MVC REST. I am making the post request which calls a method to load all the data to Amazon DynamoDB. Here is my code. RestController: @RestController...

Dynamic fields thymeleaf list iteration

spring,spring-mvc,spring-boot,thymeleaf
I'm getting a really weird error ! while iterating on list thymeleaf identified index as a property of my bean and not an index value ! <div th:each="phoneStat : *{phones}"> <select th:field="*{phones[__${phoneStat.index}__].variety}" > <option> </option> </select> <div class=" input-field col s4" > <input th:field="*{phones[__${phoneStat.index}__].number}" th:id="${'phonenumber-'+ phones[__${phoneStat.index}__]}" type="text" class="validate" /> <label...

org.apache.tiles.template.NoSuchAttributeException: Attribute 'header' not found

java,spring-mvc,tiles
i search every post on this question but didn't get an answer.please help me to solve this problem quickly. i used spring 3.1.1 and tile2.2.2.but running the project i got an error like follows : org.apache.tiles.template.NoSuchAttributeException: Attribute 'header' not found. at org.apache.tiles.template.DefaultAttributeResolver.computeAttribute(DefaultAttributeResolver.java:49) at org.apache.tiles.template.InsertAttributeModel.resolveAttribute(InsertAttributeModel.java:187) at...

loadUserByUsername execute twice using DaoAuthenticationProvider

java,spring-mvc,spring-security
I am using DaoAuthenticationProvider for authenciation but when I submit form loadUserByUsername is called twice by super.authenticate(authentication) intially it throws BadCredentialsException and then next time it login successfully This process is working fine if I do not use passwordencoder but when I use it loadUserByUsername method is called twice. Below...

Spring repository filter by using an object

spring,spring-mvc
So I'm making use of PaginAndSortingRepository<> in Spring. Now I have an object that is bound to this repository. Let's call it AuditLogEntry. So my becomes PagingAndSortingRepository<AuditLogEntry, Long>. I need to apply some filters to this repository, so I created a new model called AuditLogEntryFilter. This is not bound to...

Spring form validation using annotation and @Valid

java,spring,spring-mvc
I am having some issues with my form validation. Controller: @RequestMapping(value = REGISTER_URL, method = RequestMethod.POST) public String registerPost(@Valid RegisterForm registerForm, BindingResult result) { if (result.hasErrors()) { return REGISTER_VIEW; } System.out.println(registerForm.getPassword()); return LOGIN_VIEW; } View: <form:form action="register" commandName="registerForm" method="post"> <table> <tr> <td>Username:</td> <td><form:input path='username' /></td>...

How to keep a variable in the URL when using Spring LocaleChangeInterceptor

java,spring,jsp,spring-mvc,internationalization
I have a page at this URL http://localhost:8080/SpringExercises/admin/manageMenuDetail?id=1. I use Spring LocaleChangeInterceptor to handle languages. When I try to change the language by clicking on a link like "?lang=it" I get an error, because id is null. I suppose Spring turns .../SpringExercises/admin/manageMenuDetail?id=1 into .../SpringExercises/admin/manageMenuDetail?lang=it forgetting to write ?id=1 Can Spring...

spring mvc javax.validation.UnexpectedTypeException: No validator could be found for type: java.lang.String

java,spring,validation,spring-mvc,hibernate-validator
I try to use the validators for the first time with Spring MVC and I always get the exception: javax.validation.UnexpectedTypeException: No validator could be found for type: java.lang.String at org.hibernate.validator.engine.ConstraintTree.verifyResolveWasUnique(ConstraintTree.java:236) at org.hibernate.validator.engine.ConstraintTree.findMatchingValidatorClass(ConstraintTree.java:219) at org.hibernate.validator.engine.ConstraintTree.getInitializedValidator(ConstraintTree.java:167) at...

Ajax url parameter issue

jquery,ajax,jsp,spring-mvc
When i do a Ajax request , for the url mentioned below , it is concatenating the url value which i have mentioned along with the pathname of the URL of the page. JSP: <form:form modelAttribute="createtask" id="create-task-form" name="create-task-form"> <div class="task"> <form:input path="taskName" placeholder="enter task"/> <c:url value="/createtask/${todo.todoId }" var="createtaskUrl" /> <a...

Automatically convert JSON to Object on Flask Request

java,python,json,spring-mvc,flask
In Spring MVC + Jackson (Java), I can have this: My Object (Java) public class Project { private long id; private String self; private String key; private String name; //Getters and Setters } Spring MVC Controller ... @RequestMapping(value="/doSomething", method=RequestMethod.POST) public String doSomething(@RequestBody Project project) { System.out.println(project.getName()); return "myPage"; } ......

My CustomUsernamePasswordAuthenticationFilter is not applying

spring,spring-mvc,spring-security
I have a server which authenticates user with spring security filter. Client sending their login credentials in json format for validity. So i created my custom UsernamePasswordAuthenticationFilter filter and declared it inside http tag. Login page is already their at client application. All that client needs to do is to...

Struts exclude pattern with spring

java,spring,spring-mvc,servlets,struts2
I did a lot of homework before coming here to the experts , appreciate any pointers on my question I need to run a merged (not integrated) app that was basically combined version of struts2 and Spring and some base servlets. Was able to get the combined war file up...

Static util class with Spring, unsure if I should make it a SpringBean, design concerns

java,spring,spring-mvc,static
Quick high level concept of my design.. CLI tool to create AWS EBS snapshots CLI tool just calls Java class com.util.SnapshotUtil com.util.Snapshot calls AWS Interfacing class com.aws.AWSAdapter example usage from command line.. cli-tool create-snapshot.. calls java class eventually calling below method SnapshotUtil.createSnapshot() // statically call AWSAdapter.createSnapshot(); Currently everything is static...

what is the main difference between Spring and Rest services

java,spring-mvc
I am new to J2EE. I found that Spring MVC could also perform the same tasks as REST. What is the main difference.

how to return two lists from controller class in spring mvc

java,hibernate,jsp,spring-mvc,tiles
I have two tables call maintab,subtab for generate menubar. maintab has maitabId ,main_tab_name subtab has: sub_tb_ID ,main_tb_id,subtab_name ,Url I want to get two list containig list1=maintabid & maintabname list2=subtabname,maintabID & url I want to return the two list using spring mvc. And retrieve in jsp page to populate a menu.Please...

spring form input fields type attribute

spring,spring-mvc
I am converting some plain HTML to using spring form tags.Although it looks like spring form input does not have the attribute type. I was able to successfully pass a hidden variable as follows: <form:input type="hidden" name="displayId" id="displayIdentifier" path="displayIdentifier" value="${value1}"/> Earlier the plain HTML was as follows: <input type="hidden" name="displayId"...

Pass parameter in request while using spring vmc form

spring-mvc
I am using spring mvc form to submit request. I have a hidden variable which i want to pass to the controller. The hidden variable path is using a property which present in the model attribute object. Now I want to pass this hidden variable to the controller. For this...

REST-API Different Content-Type on Error Response

java,json,api,rest,spring-mvc
Since some weeks I'm working on an rest api using spring-mvc. The REST-API is working properly and I`m almost done until one last problem when it comes to error handling with specific error-objects. The REST-API is using JSON as format to serialize Java-Objects. When an error occurs during service-execution an...

Default Spring bean when profile is not present

java,spring,spring-mvc,spring-profiles
I'm using Spring MVC controllers, and I'd like to make some extra request-mapped methods available during development. I can do this using Spring profiles: @Controller @Profile("!dev") public class DefaultController { } @Controller @Profile("dev") public class DevController extends DefaultController { } But ideally, I'd rather not pollute the production classes' code...

Not Able to Resolve View Using Spring boot

spring,spring-mvc,spring-boot
I have put all jsp on classpath in views folder. Folder structure is : src/main/resources/ src/main/resources/static/ src/main/resources/static/views/ src/main/resources/static/views/*.jsp src/main/resources/static/views/*.png I am able to retrieve images file from static folder. But When It comes to jsp I am getting following error. While hitting url:http://localhost:9001/login There was an unexpected error (type=Not Found,...

Spring controller unit testing with spring-test-mvc is failing

java,spring,unit-testing,spring-mvc
I am learning unit testing of spring controller with EasyMock and Spring test framework. I have done a simple unit testing for my controller. import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.servlet.ModelAndView; import...

Spring Portlet Jquery Ajax post to Controller

javascript,jquery,json,spring-mvc,spring-portlet-mvc
EDIT: The startdate and enddate are joda dateTime in the POJO and the error I get is: SystemOut O 14:10:16.040 [WebContainer : 2] DEBUG org.springframework.beans.BeanUtils - No property editor [org.joda.time.DateTimeEditor] found for type org.joda.time.DateTime according to 'Editor' suffix convention ... SystemOut O Error::Failed to convert property value of type 'java.lang.String'...

HTTP Status 500 - Expected session attribute 'consent'

spring-mvc
this is my html form of consents. after posting the inputs i get error on the browser <form th:object="${consent}" action="../users/userDetails.html" th:action="@{${#httpServletRequest.servletPath}}" method="post"> <fieldset> <div class="col-sm-7 col-md-6 col-lg-5"> <label for="last_name">Service Provider</label> <select id="provider" name="provider" class="form-control" th:onchange="'javascript:showPIIDoc(this.value);'"> <option th:value="0" >Select a Service Provider</option> <option...

Spring MVC + Tiles + Spring Security = The requested resource is not available

java,spring,spring-mvc,spring-security,tiles
I have to say the equation in the title drives me crazy. As soon as I add the DelegatingFilterProxy to web.xml I get the 'Error 404 The requested resource is not available'. Otherwise the web app works fine. I am sure the problem with my configuration but I just cannot...

Spring - configure Jboss Intros for xml with java config?

java,xml,spring,spring-mvc,jboss
I'm in the process of writing a spring web app and want to convert my objects to xml without annotations. I know with xml config you can do this: <bean id="jaxb2Marshaller" class="software.bytepushers.userprofile.models.JaxbIntroductionsMarshaller"> <property name="classesToBeBound"> <list> <value>software.bytepushers.userprofile.models.Person</value> <value>software.bytepushers.userprofile.models.WebServiceResponse</value> </list> </property> <property...

Server Side Pagination with jQuery Data Tables plugin

jquery,spring-mvc,datatables
How can I achieve server side pagination using data table? Currently, on load of page I am initializing the data table & filling the table with Data (JSON) coming from database via Java Spring controller. I am making an Ajax call by passing search criteria in query string. Since we...

How to send current page number in Ajax request

javascript,jquery,ajax,spring-mvc,datatables
I am using jQuery DataTable to display huge amount of data in a table. I am getting data page wise on Ajax request like this: var pageNo = 1; $('#propertyTable').dataTable( { "processing": true, "serverSide": true, "ajax": "${contextPath}/admin/getNextPageData/"+pageNo+"/"+10, "columns": [ { "data": "propertyId" }, { "data": "propertyname" }, { "data": "propertyType"...

How to get some utf-8 characters using hibernate and spring mvc in database?

java,spring,hibernate,spring-mvc,tomcat
I have developed small server program. When I extract tuple from database, some characters become ÇѱÛÃàÁ¦. I modify server.xml. However ÇѱÛÃàÁ¦ characters still appear. Help me. How can I get correct characters? This is my server.xml. (I use apache tomcat 7.0 server.) <?xml version="1.0" encoding="UTF-8"?> <!-- Licensed to the Apache...

Spring Security java.lang.StackOverflowError exception after all providers

java,spring,spring-mvc,spring-security
Environment: Spring 4.1.6 Spring Security 4.0.1 I have 2 authentication providers - one that hits ActiveDirectory, and then one that hits a custom database provider I've created. Logging in as a user that is in either of those environments works perfectly. The user is authenticated and the app continues. However,...

Custom Spring annotation for request parameters

java,spring,spring-mvc,spring-annotations
I would like to write custom annotations, that would modify Spring request or path parameters according to annotations. For example instead of this code: @RequestMapping(method = RequestMethod.GET) public String test(@RequestParam("title") String text) { text = text.toUpperCase(); System.out.println(text); return "form"; } I could make annotation @UpperCase : @RequestMapping(method = RequestMethod.GET) public...

Angularjs - Spring MVC Rest : how to handle exceptions

java,angularjs,spring-mvc
I am developping an single page app with angularjs and Spring Mcv Rest. I am calling my service (mail sending with javax mail) like that in Angularjs : SendProformaFax.get({idCommande:$scope.commande.id}) And on server side my service : @RequestMapping(value = "/sendProformaFax/{idCommande}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @Timed public void imprimeProforma(@PathVariable String...

How to apply HandlerInterceptor to Spring Boot Actuator endpoints?

java,spring,spring-mvc,spring-boot
I'm working with Java 8 and Spring 1.2.3 to build an application running inside a Tomcat 7 container. I do intercept every single call to my web application using a very simple HandlerInterceptor, that logs the overall time taken to create a response and the return code for every request....

Spring-MVC, Hibernate : Creating DTO objects from Domain objects

java,spring,hibernate,spring-mvc,dto
I am working on a Spring-MVC application in which I am trying to search for List of GroupNotes in database. The mapping in my project is GroupCanvas has one-to-many mapping with GroupSection and GroupSection has one-to-many mapping with GroupNotes. Because of these mappings, I was getting LazyInitializationException. As suggested on...

How get value from property file to input in springConfig.xml

java,xml,spring-mvc
I want to get the property value in email.properties file to input in the springConfig.xml. but there is an error occur. here is my code below springConfig.xml <bean class="org.springframework.mail.javamail.JavaMailSenderImpl" id="mailSender"> <property name="host" value="${email.host}" /> <property name="protocol" value="${email.protocol}" /> <property name="port" value="${email.port}" /> <property name="username" value="${email.username}"/> <property name="password" value="${email.password}" />...

Streaming data with Spring MVC

java,spring,spring-mvc,twitter,twitter4j
I'm looking to set up a Twitter stream using Twitter4J. I plan to be able to search using a keyword. I also would like to use Spring MVC as this is something I've used a lot recently. However, I would like to stream an infinite amount of tweets without stopping...