spring-mvc

How to autowired spring service into a jsp?

一世执手 提交于 2020-02-03 08:34:27
问题 As mentioned in the title, i need to autowire a service in my page.jsp.. " i know that's not recommended to do it " <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> <%@ page import="org.springframework.context.ApplicationContext"%> <%@ page import="org.springframework.web.servlet.support.RequestContextUtils"%> <%@ page import="com.fussa.fyby.service.Test"%> <%@ page import="com

How to display byte array from a model in Thymeleaf

眉间皱痕 提交于 2020-02-03 08:30:27
问题 I want to display all my products info, but I have problem with showing a product image. I get my products from DB and then I add them to Model , but don't know why only image don't display. In HTML it looks like this: <div class="row"> <div class="col-sm-3 my-2 d-flex align-content-stretch flex-wrap" th:each="product : ${products}"> <div class="card"> <img class="card-img-top" th:src="${product.image}"> <div class="card-body"> <h5 class="card-title" th:text="${product.name}">Product name</h5

How to display byte array from a model in Thymeleaf

走远了吗. 提交于 2020-02-03 08:28:28
问题 I want to display all my products info, but I have problem with showing a product image. I get my products from DB and then I add them to Model , but don't know why only image don't display. In HTML it looks like this: <div class="row"> <div class="col-sm-3 my-2 d-flex align-content-stretch flex-wrap" th:each="product : ${products}"> <div class="card"> <img class="card-img-top" th:src="${product.image}"> <div class="card-body"> <h5 class="card-title" th:text="${product.name}">Product name</h5

How to display byte array from a model in Thymeleaf

a 夏天 提交于 2020-02-03 08:28:09
问题 I want to display all my products info, but I have problem with showing a product image. I get my products from DB and then I add them to Model , but don't know why only image don't display. In HTML it looks like this: <div class="row"> <div class="col-sm-3 my-2 d-flex align-content-stretch flex-wrap" th:each="product : ${products}"> <div class="card"> <img class="card-img-top" th:src="${product.image}"> <div class="card-body"> <h5 class="card-title" th:text="${product.name}">Product name</h5

Spring controller get request/response

岁酱吖の 提交于 2020-02-03 04:04:06
问题 How do I get the request/response that I can setcookie? Additionally, at the end of this method, how can I can redirect to another page? @RequestMapping(value = "/dosomething", method = RequestMethod.GET) public RETURNREDIRECTOBJ dosomething() throws IOException { .... return returnredirectpagejsp; } 回答1: How about this: @RequestMapping(value = "/dosomething", method = RequestMethod.GET) public ModelAndView dosomething(HttpServletRequest request, HttpServletResponse response) throws

Spring-MVC, Java : Creating URL for image saved on FileSystem

我的梦境 提交于 2020-02-02 15:19:26
问题 I am working on a Spring-MVC application in which for the user, we are saving the thumbnail on the filesystem itself. Now for chat, I want to create a URL for the thumbnail saved on the filesystem and pass it on in the frontend. For example : Image is saved at /home/username/datadir/personid.png I would like to give the url something like : domainname.com/personid.png Please note PersonId is unique, so I can use that constraint. The part to save the image is complete, I just don't know how to

Unable to redirect from one controller to another controller-Spring MVC

你离开我真会死。 提交于 2020-02-02 14:41:44
问题 I am new to spring MVC and facing some error. I have two controllers as below 1) LoginController.java @Controller @RequestMapping("/log") public class LoginController { @Autowired private LoginService service; @RequestMapping(value="login.spring",method=RequestMethod.GET) public ModelAndView prepareLoginForm() { System.out.println("In get"); return new ModelAndView("Login", "login", new Login()); } @RequestMapping(value="login.spring",method=RequestMethod.POST) public ModelAndView

Spring WebClient call to Rest-Service: Exception from Jaxb2XmlDecoder

十年热恋 提交于 2020-02-02 06:30:26
问题 I'm currentlty struggling with Springs reactive WebClient calling a Rest-Service. I get an UnsupportedOperationException of the decodeToMono -function from Springs Jaxb2XmlDecoder . public Mono<T> decodeToMono(Publisher<DataBuffer> inputStream, ResolvableType elementType, @Nullable MimeType mimeType, @Nullable Map<String, Object> hints) { throw new UnsupportedOperationException(); } My WebClient call: ResponseEntity<MyAsyncResponse> result = webClient.post() .contentType(MediaType.APPLICATION

Spring Form Controller with DWR

Deadly 提交于 2020-02-02 06:19:34
问题 I am using spring and DWR combination,When i do ajax request from DWR.I want to access entire form values bind to the bean in my DAO layer. I didn't find any examples for Spring form controller with DWR. Any suggestions or help appreciated. Thanks in Advance. Regards, Raj 回答1: Considering your problem is how to create Spring-DWR integration, so that you can simulate Spring controller calls from Java, try it like this: Your Spring XML config: <bean id="myController" class="pkg.MyController">

Spring MVC project not able to publish and run… Message: Failed to introspect annotations

给你一囗甜甜゛ 提交于 2020-02-01 18:33:55
问题 I have a Spring MVC application(4.1.1-Release version). When I try to publish and Run on Server I am getting the below mentioned error. Additional Information Using Spring Tool Suite 3.6.1 Spring version 4.1.1-RELEASE It is a maven project It does not have any compilation error when i do mvn clean install , the build is successful org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'homeController' defined in file [/home/abc/Tools/sts-bundle/pivotal-tc