spring-mvc

response code 500 when returning an object using @ResponseBody

你说的曾经没有我的故事 提交于 2020-01-05 11:02:20
问题 I'm fairly new to spring Restful programming The requirement to use the controller method as a rest service, so I'm trying to return an object in a JSON format, but for some reason I'm getting a response code as 500 with no errors and exceptions in log files. But it is successfully working if I the return type is of a string rather an object I'm using the jackson dependencies and I'm configuring in context file and in a assumption that converts the object to json format and puts in the

Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener

人走茶凉 提交于 2020-01-05 10:36:36
问题 I have been struggling at successfully implementing openId in spring from last 3 weeks now. Please help me out with it. I tried to implement it from http://krams915.blogspot.in/2011/02/spring-security-3-openid-login-with_13.html, now i m getting an exception. console log: SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener java.lang.NoClassDefFoundError: org/openid4java/consumer/ConsumerException at java.lang

Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener

安稳与你 提交于 2020-01-05 10:36:12
问题 I have been struggling at successfully implementing openId in spring from last 3 weeks now. Please help me out with it. I tried to implement it from http://krams915.blogspot.in/2011/02/spring-security-3-openid-login-with_13.html, now i m getting an exception. console log: SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener java.lang.NoClassDefFoundError: org/openid4java/consumer/ConsumerException at java.lang

Spring MVC: How to store € character?

丶灬走出姿态 提交于 2020-01-05 10:10:17
问题 I am using Spring 3 MVC and I have setup a form to capture input from a user. This form includes a textarea for a description String in my model object, Event. My corresponding controller looks like this: @RequestMapping(value = "/admin/event/{eventId}/edit", method = RequestMethod.POST) public String updateEvent(@ModelAttribute Event event) { logger.info("updateEvent(): Event description: " + event.getDescription()); return "redirect:/admin/event/" + event.getId() + "/edit"; } Whenever I

spring mvc 3 populate javascript var from property file

*爱你&永不变心* 提交于 2020-01-05 09:28:21
问题 I need to populate a JavaScript variable with a property value (that defined in a property file) when page get loaded . i am using spring mvc 3. is there any best way to do it? appreciate if someone give me some clue. Thanks in advance. 回答1: Create an initializer method in the javascript file output the properties in the page that includes the js. so that they form a valid javascript structure (array, object, whatever) pass the structure to the initializer. The 1st step may look like (in the

Not able to run sql query with Mybatis

余生颓废 提交于 2020-01-05 09:15:08
问题 I am trying to run a simple sql query using mybatis but its giving me following exception java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for com.mycom.myproject.db.mybatis.dao.UserMapper.countByExample org.apache.ibatis.session.Configuration$StrictMap.get(Configuration.java:660) org.apache.ibatis.session.Configuration.getMappedStatement(Configuration.java:495) org.apache.ibatis.session.Configuration.getMappedStatement(Configuration.java:488) org.apache

spring web-mvc 4 java config doesn't work

一曲冷凌霜 提交于 2020-01-05 08:23:06
问题 I'm trying to run elementary spring-4 web-mvc application without xml configuration at all. I've looked spring documentation and examples, but it didn't work for me. My controller: package com.nikolay.exam.controller; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; @Controller public class HomeController {

Can't download file. Browser opens it instead.

孤人 提交于 2020-01-05 08:21:13
问题 I have tried a lot of contentTypes and headers I have seen here but still can't figure out what I am doing wrong. I have the following Spring Controller: @RequestMapping(value = "/anexo/{id}", method = RequestMethod.GET) @ResponseBody public ResponseEntity<String> getAnexoById(@PathVariable int id, HttpServletResponse response) { Anexo a = anexoDAO.getAnexo(id); if (a == null) return new ResponseEntity<String>(HttpStatusMessage.NOT_FOUND, HttpStatus.NOT_FOUND); else { try { File dir = new

Spring Security 3.1 redirect to login doesn't work

馋奶兔 提交于 2020-01-05 07:25:12
问题 I use Spring 3.1 with Spring Mvc and Spring Security. <security:http auto-config="true" use-expressions="true" access-denied-page="/views/not-authorized.jsp"> <security:form-login login-page="/login.html" login-processing-url="/j_spring_security_check" default-target-url="/main.html" always-use-default-target="false" authentication-failure-url="/login.html?error=true" /> <security:logout logout-url="/j_spring_security_logout" invalidate-session="true" logout-success-url="/login.html"/> <

Parametrize Bean factory by type in spring boot

元气小坏坏 提交于 2020-01-05 07:19:07
问题 I have a couple of interfaces which define some services: public interface Service { // marker } public interface ServiceA extends Service { public method doA(AParameter a); } public interface ServiceB extends Service { public method doB(BParameter b, AnotherParameter c); } Their implementations are always built the same way: @Bean public ServiceA getService() { return new Servicebuilder().build(ServiceA.class); } @Bean public ServiceB getService() { return new Servicebuilder().build(ServiceB