VV
5 question(s)
0 answer(s)
Avatar
0
VV Beginner
VV Beginner
Api có gửi file dùng spring boot
Cần truyền xuống thông tin là 1 list Customer gồm: name, type, và 1 danh sách Document gồm documentType và file <p> public class CustomerInfo { </p> <p> private String customerName; </p> <p> private String customerType; </p> <p> private List<CustomerFileDTO> files; </p> <p> } </p> <p> public class CustomerFileDTO { </p> <p> private String documentType; </p> <p> private MultipartFile file; </p> <p> } </p> <p> Cách nào là tối ưu nhất để xử lý đưa list customer này xuống và lấy được file vậy ạ. Cho e xin cách truyền request xuống dễ xử lý với ạ. list customer này max size =5 vì nó đẩy xuống để lưu thông tin của 1 phiếu xử lý </p>
Answer
Avatar
1
VV Beginner
VV Beginner
Lỗi CORS bên FE khi connect websocket
<pre> @Bean CorsConfigurationSource corsConfigurationSource() { return new CorsConfigurationSource() { @Override public CorsConfiguration getCorsConfiguration(HttpServletRequest request) { var cors = new CorsConfiguration(); cors.setAllowedOrigins(List.of("*")); cors.setAllowedMethods(List.of("GET", "POST", "PUT", "DELETE", "OPTIONS")); cors.setAllowedHeaders(List.of("*")); return cors; } }; } @Override protected void configure(HttpSecurity http) throws Exception { // @formatter: off http .csrf() .disable() .cors() .configurationSource(corsConfigurationSource()) .and() .exceptionHandling() </pre> <p> Còn đây là config websocket </p> <pre>public class WebSocketConfig implements WebSocketMessageBrokerConfigurer { @Override public void configureMessageBroker(MessageBrokerRegistry config) { config.enableSimpleBroker("/topic"); config.setApplicationDestinationPrefixes("/app"); } @Override public void registerStompEndpoints(StompEndpointRegistry registry) { registry.addEndpoint("/websocket") .setAllowedOriginPatterns("*").withSockJS(); } </pre> <p> Và khi em connect socket ở bên FE thì lỗi như này nè a :( </p> <img class="alignnone size-full wp-image-8601" src="https://stackask.com/wp-content/uploads/2022/11/loicors.png" alt="" /> <pre> Access to XMLHttpRequest at 'http://localhost:8082/emaf/api/v1/websocket/info?t=1669656213092' from origin 'http://127.0.0.1:5500' has been blocked by CORS policy: The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute. &lt;/pre&gt; Mong a hướng dẫn e cách fix bên BE ạ.
Answer
Avatar
0
VV Beginner
VV Beginner
[Sharing]DestinationVariable trong Spring websocket
Em đang dùng <code>@SendTo("/topic/public") </code>ở bên BE để bên FE có thể subscribe. Nhưng vấn đề hiện tại em muốn nó subscribe tới 1 topic riêng thì em dùng <code> @SendTo("/topic/public/{eventId}")</code> để subscribe theo 1 event nào đó. Em thấy có cái <p> @DestinationVariable nhưng e đang dùng phiên bản Spring 2.5.5 hình như nó không support ạ. </p>
Answer
Avatar
1
VV Beginner
VV Beginner
WebSocket không connect được
Cho em hỏi là em đang thử làm cái chat websocket. Em có xem code trên mạng và tách nó ra BE và FE. Nhưng chạy thì nó không connect được. <p> </p> <img class="content-img" src="https://stackask.com/wp-content/uploads/2022/11/FE.png" /> <p> </p> <p> nó chạy dòng 26 xong là không pass được tới dòng 27 ạ. </p> <p> </p> <p> còn đây là code BE ạ. </p> <p> </p> <img class="content-img" src="https://stackask.com/wp-content/uploads/2022/11/BE.png" />
Answer
Avatar
2
VV Beginner
VV Beginner
Java Developer: Để lên middle level thì cần học gì
Chào mọi người, hiện tại em là junior java của một công ty. Em muốn hỏi là để thành midle java thì cần học nắm những kiến thức gì ạ? Với những kiến thức gì mà một junior java developer cần phải có ạ?
Answer