spring-mvc

How to cancel @jsonIgnore in specific method

与世无争的帅哥 提交于 2021-01-29 10:52:36
问题 I have a domain javabean, some bean hvae a lot of information with password and login Ip, I use the @jsonIgnore to filter that property which I dont want the end user know. But there has a problem,In other method I use the same javabean to send back to front side,but now I need some property from this domain has anyway can cancel this @jsonIgnore in some specific method? @JsonIgnore private String address; private Integer drawnum; but now I need address , I cant do this..... I dont want to

Springboot does not serve static content

▼魔方 西西 提交于 2021-01-29 10:27:14
问题 I am not able to access static content (angular app) or even a simple index.html file from spring-boot. I keep getting 404 error. Spring is not serving me with those static files. I have the problem since I have upgraded to Spring-Boot 2.2.4. I had to upgrade to counter Zip64 issue. I have this line in my application.properties: spring.resources.static-locations=classpath:/resources/,classpath:/static/ I also have my own staticResourceConfiguration class. In my WebSecurity class, i have the

How to read request body in HandlerInterceptor in Spring boot?

社会主义新天地 提交于 2021-01-29 10:04:16
问题 I have spring boot and I need to log user action in DB, so I wrote HandlerInterceptor: @Component public class LogInterceptor implements HandlerInterceptor { @Autovired private LogUserActionService logUserActionService; @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws IOException { String userName = SecurityContextHolder.getContext().getAuthentication().getName(); String url = request.getRequestURI(); String queryString =

UriComponentsBuilder/MvcComponentsBuilder usage in a Spring Boot Test

橙三吉。 提交于 2021-01-29 09:21:38
问题 I've put a very simple sample project on GitHub to reproduce the problem. The main issue is that I have a PersonController that has a PutMapping to create a new person. In order to populate the Location header with the URL to fetch that person, I add the UriComponentsBuilder as parameter for that PutMapping , as you can see here: @PostMapping public ResponseEntity<Person> add(@RequestBody final PersonForCreate personForCreate, UriComponentsBuilder uriComponentsBuilder) { Person newPerson =

HTTP status 406 -Not Acceptable Spring mvc

≯℡__Kan透↙ 提交于 2021-01-29 08:30:07
问题 Error is HTTP Status 406 – Not Acceptable The target resource does not have a current representation that would be acceptable to the user agent, according to the proactive negotiation header fields received in the request, and the server is unwilling to supply a default representation. This is a controller code @RequestMapping(value="/welcomes", method = RequestMethod.GET, headers="Accept=application/json") public @ResponseBody List<UserBean> welcome(@ModelAttribute UserBean userBean) { List

Absolute ordering not working - More than one fragment with the name [spring_web] was found. This is not legal with relative ordering

自古美人都是妖i 提交于 2021-01-29 07:55:44
问题 I was trying to build a spring MVC project and set up the basic libraries and XML files. however, when I tried to run the spring application it is throwing error regarding relative ordering. I have added tag in my web.xml file but still, it is not working. It throws the following error SEVERE: A child container failed during start java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost]

Not able to use th:field of thymeleaf

本小妞迷上赌 提交于 2021-01-29 07:43:13
问题 I'm trying to develop a project with spring boot which will be used by employees to applicate for day off or vacations, i am also using crud operations as Rest web services, but i'm having a problem with the th:field of thymeleaf which generates the error: org.thymeleaf.exceptions.TemplateProcessingException: Error during execution of processor 'org.thymeleaf.spring5.processor.SpringInputGeneralFieldTagProcessor' (template: "admin/home" - line 81, col 54) Below you find the code of the

Spring Boot - Hibernate - OneToMany - foreign key

隐身守侯 提交于 2021-01-29 07:34:15
问题 I would like to ask a theoretical question. So let's assume I'm using spring boot and hibernate and I would like to persist the following data structure. @Entity @Table(name = "shoppingbasket") @NoArgsConstructor @AllArgsConstructor public class ShoppingBasket { @Getter @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; @Getter @Setter @Column(name = "userId", unique = true) private String userId; @Getter @Setter @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType

Is possible to get web application full url from Spring service that is invoked by task?

偶尔善良 提交于 2021-01-29 07:29:16
问题 I have service which is not invoked by user request, but by task. Now I need to send email from this task, and email contains link to my web application, how can I get full url of my application so that my email can link back to my web application? Example of service: @Service public class MyService { @Scheduled(cron="0 */10 * * * *") @Transactional public void myTask() throws IOException, ParseException { // Now I have to send email with my app url, but how can I get it here ? } } 回答1: You

post request with form-data from angular to spring

末鹿安然 提交于 2021-01-29 06:48:48
问题 i am trying to send a post request to my spring rest api using angular and its http library. currently in post-man (sucessfully) i am sending the data in this way: The format is form-data The key is reqData(mandatory) The Value is json(mandatory) how to send the data in the same way via angular? currently, this is how my data looks like: onSignIn(form: NgForm) { const email = form.value.email; const password = form.value.password; const reqData = { 'app_uname': email, 'app_pass': password };