spring-mvc

How to show image from H2 database to Thymeleaf?

橙三吉。 提交于 2020-01-05 23:59:27
问题 I'm doing spring boot, using H2 database, thymeleaf view. I have a form to upload image to save into H2 database(byte[] image), In thymeleaf, how to show image? anyone tell me the solution? controller: @RequestMapping(value = "user/new", method = RequestMethod.GET) public String newBeans(Model model) { model.addAttribute("usersss", new Beans()); return "userform"; } @RequestMapping(value = "user", method = RequestMethod.POST) public String saveUser(Beans beans) { RepositoryUser.save(beans);

How to POST JSON object to spring controller?

青春壹個敷衍的年華 提交于 2020-01-05 23:29:16
问题 I have spring controller: @RequestMapping(value = "/add", method = RequestMethod.POST, consumes = "application/json") public @ResponseBody ResponseDto<Job> add(User user) { ... } I can POST the object like this with APACHE HTTP CLIENT: HttpPost post = new HttpPost(url); List nameValuePairs = new ArrayList(); nameValuePairs.add(new BasicNameValuePair("name", "xxx")); post.setEntity(new UrlEncodedFormEntity(nameValuePairs)); HttpResponse response = client.execute(post); In controller I get user

How to POST JSON object to spring controller?

╄→尐↘猪︶ㄣ 提交于 2020-01-05 23:23:29
问题 I have spring controller: @RequestMapping(value = "/add", method = RequestMethod.POST, consumes = "application/json") public @ResponseBody ResponseDto<Job> add(User user) { ... } I can POST the object like this with APACHE HTTP CLIENT: HttpPost post = new HttpPost(url); List nameValuePairs = new ArrayList(); nameValuePairs.add(new BasicNameValuePair("name", "xxx")); post.setEntity(new UrlEncodedFormEntity(nameValuePairs)); HttpResponse response = client.execute(post); In controller I get user

How to POST JSON object to spring controller?

淺唱寂寞╮ 提交于 2020-01-05 23:22:31
问题 I have spring controller: @RequestMapping(value = "/add", method = RequestMethod.POST, consumes = "application/json") public @ResponseBody ResponseDto<Job> add(User user) { ... } I can POST the object like this with APACHE HTTP CLIENT: HttpPost post = new HttpPost(url); List nameValuePairs = new ArrayList(); nameValuePairs.add(new BasicNameValuePair("name", "xxx")); post.setEntity(new UrlEncodedFormEntity(nameValuePairs)); HttpResponse response = client.execute(post); In controller I get user

How to POST JSON object to spring controller?

梦想的初衷 提交于 2020-01-05 23:21:08
问题 I have spring controller: @RequestMapping(value = "/add", method = RequestMethod.POST, consumes = "application/json") public @ResponseBody ResponseDto<Job> add(User user) { ... } I can POST the object like this with APACHE HTTP CLIENT: HttpPost post = new HttpPost(url); List nameValuePairs = new ArrayList(); nameValuePairs.add(new BasicNameValuePair("name", "xxx")); post.setEntity(new UrlEncodedFormEntity(nameValuePairs)); HttpResponse response = client.execute(post); In controller I get user

Spring and JSP EL not being processed

大城市里の小女人 提交于 2020-01-05 19:35:20
问题 We are running Tomcat 6.0 with Spring 3.0.5 an for some reason we can not get the jsps to evaluate the ${blah}. This is a maven project with many separate modules if that matters, Eclipse Helios. Here is a snipped of my web.xml <web-app id="WebApp_ID" version="2.5" 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"> <display-name>xc.rio</display

How to send @Requestbody and @Requestpart together in spring

泪湿孤枕 提交于 2020-01-05 17:49:31
问题 I want to pass json and file together in the controller using curl. I have following method in controller. @PostMapping(value = /api/campaign, headers = {"content-type=multipart/mixed","content-type=multipart/form-data"}) @ResponseBody @ResponseStatus(HttpStatus.CREATED) public @Valid ResponseDTO campaignCreator (@Valid @RequestBody CampaignCreatorDTO campaignCreatorDTO, @RequestPart("file") MultipartFile adGraphic){ } Below is the curl command curl -i -X POST -H "Content-Type: multipart

Spring:No mapping found for HTTP request with URI

拥有回忆 提交于 2020-01-05 17:15:12
问题 I have started using spring and am encountering this error No mapping found for HTTP request with URI [/SpringSocialSample/login.htm] in DispatcherServlet with name 'SpringSocialSample' I figured that login.htm cant be located by dispatcher servlet My SpringSocialSample-servlet.xml <context:component-scan base-package="com.social.spring.controllers" /> <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver" p:prefix="/WEB-INF/views/" p:suffix=".jsp" /

Failed to load resource: the server responded with a status of 404 (Not Found) in spring mvc

最后都变了- 提交于 2020-01-05 15:25:10
问题 I am trying to load the css file into jsp, it is not loading and showing the message Failed to load resource: the server responded with a status of 404 (Not Found).the following is my code <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Bootstrap Form With Spring Mvc Example</title> <link href="<c:url value='/resources/css/bootstrap.css'/>" rel="stylesheet" media="screen"> </head> in

Failed to load resource: the server responded with a status of 404 (Not Found) in spring mvc

。_饼干妹妹 提交于 2020-01-05 15:24:40
问题 I am trying to load the css file into jsp, it is not loading and showing the message Failed to load resource: the server responded with a status of 404 (Not Found).the following is my code <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Bootstrap Form With Spring Mvc Example</title> <link href="<c:url value='/resources/css/bootstrap.css'/>" rel="stylesheet" media="screen"> </head> in