spring-mvc

Spring mvc @RequestMapping on class level and method level 404 Status

两盒软妹~` 提交于 2021-02-05 08:21:06
问题 I know that there are lot of posts here with the same problem, but none of them seem to help me, so this will probably be a duplicate. Im creating a spring mvc application using Maven, i have only one controller with one method. When i put the request mapping annotation only on the class level the application works fine but when i put it on the class level and the method level and i send a request like this: localhost:8080/myapplication/planification/projet i get 404 error: HTTP Status 404 -

request has been blocked; the content must be served over HTTPS

雨燕双飞 提交于 2021-02-05 08:11:39
问题 I'm doing application with spring security and Spring MVC in back end and Angular in front end. My problem is that I do the logged in correctly, but the problem in logged out I implemented correctly in my localhost: http://localhost:8080 worked without problem. When I change it to https:// I get this error: Mixed Content: The page at '' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint ''. This request has been blocked; the content must be served over HTTPS. I want to

using thymeleaf +spring to create custom tags (just like JSP)

半腔热情 提交于 2021-02-04 19:27:05
问题 I am trying to use Thymeleaf to create custom tags, just like in JSP. The tag I have now is: <select th:include="fragments/combobox :: combobox_beans (beans=${@accountService.getAccounts()}, innerHTML='id,description,currency', separator=' - ', dumbHtmlName='List of accounts', name='sender' )" th:remove="tag"></select> The purpose is just defining the beans list, the properties of the bean to show on screen, the separator between them, the default value when shown as a native template, and

Serve JSP stored in DB

雨燕双飞 提交于 2021-02-04 13:44:05
问题 I want to server a JSP page that is stored in a database as a blob. So if a request comes in at the url http://mydomain.com/app/list.jsp I know to go to the DB to retrieve the resource list.jsp. I am using spring and tiles, so have adispatcher servlet and controllers set up and working in traditional sense. Would this be similar in principle to the resource servlet that spring web has to serve javascript files and messages from within jar? Note that the JSPs would not just be static HTML, I

Get _csrf in spring controller

天涯浪子 提交于 2021-02-04 13:37:06
问题 How can I get _csrf object (?!) in spring controller? I've configured Spring Security and can get ${_csrf} request attribute in jsp files. I've tried: CsrfToken _csrf = (CsrfToken) session.getAttribute("CsrfToken"); CsrfToken _csrf = (CsrfToken) session.getAttribute("_csrf"); the result is null; Thanks in advance! 回答1: In debug I saw a session attribute with a key "org.springframework.security.web.csrf.HttpSessionCsrfTokenRepository.CSRF_TOKEN". I viewed the HttpSessionCsrfTokenRepository

Basic GET request failed Angular and Spring

蹲街弑〆低调 提交于 2021-01-29 15:30:38
问题 I am trying to make a simple request from angular to spring. I used bare bone spring web and spring security and simple angular(9) request. Let me share my Java and Angular code. Java Code @RestController @CrossOrigin(origins = "http://localhost:4200") public class Main { @RequestMapping("/hello") public Map<String,Object> home(){ Map<String, Object> model = new HashMap<String, Object>(); model.put("id", UUID.randomUUID().toString()); model.put("content", "Hello from Backend"); return model;

How to use input radio button with thymeleaf and Spring MVC

放肆的年华 提交于 2021-01-29 14:34:13
问题 I would like to get a destination address from a input radio button list. The DestinationAddress class is the following: public class DestinationAddress { private Integer destinationAddressId; private String name; private Location location; private User owner; public DestinationAddress(String name, Location location, User owner) { this.name = name; this.location = location; this.owner = owner; } public DestinationAddress() { } // getter and setter } The controller who handles the get and post

How to use Pageable as get-query parameter in spring-data-rest?

故事扮演 提交于 2021-01-29 13:21:31
问题 I have a simple query controller that takes query parameters (as Person dto) and a Pageable : @RestController public class PersonController { @GetMapping("/persons") public Object search(org.springframework.data.domain.Pageable pageable, Person form) { repository.findAll(form, pageable); } } The pageable can take both sort and page parameters as follows: http://localhost:8080/persons?sort=age,desc&page=5 Problem: for the sort, I want to add order hints like NULLS_LAST or NULLS_FIRST .

How to pass an argument to a Spring Boot REST Controller?

霸气de小男生 提交于 2021-01-29 13:19:51
问题 I am trying to pass an argument to my @RESTController Spring Boot class. In the @POSTMapping method I want to use a method of a self defined Java class for processing the received body and returning a response. The Spring application is launched in Application.java. The Controller-Object seems to get created implicitly. I already tried adding a constructor to my RESTController class. But I couldn't find a way to call that constructor with an argument. // Application.java public static void

Application-wide process in SpringMVC

会有一股神秘感。 提交于 2021-01-29 11:11:16
问题 Suppose I have a certain operation that should be available to every process running in Spring MVC. Say string normalization-- i need to run a method that normalizes the string fields before doing anything else on that form/data. One thing specific to do is, to normalize the String fields on every input form before they are dispatched to the back-end services. Likewise, that operation (normalization) should be run on data from the back-end before it is dispatched to the view component. One