我有使用angular-cli生成的Angular 2(版本2.0.0 - 最终版)app.
当我创建一个组件并将其添加到AppModule
声明数组时,它一切都很好,它可以工作.
我决定将组件分开,所以我创建了TaskModule
一个组件TaskCard
.现在我想用TaskCard
在的组成部分之一AppModule
(的Board
成分).
的AppModule:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { AppComponent } from './app.component';
import { BoardComponent } from './board/board.component';
import { LoginComponent } from './login/login.component';
import { MdButtonModule } from '@angular2-material/button';
import { MdInputModule } from '@angular2-material/input';
import { MdToolbarModule } from '@angular2-material/toolbar';
import …
Run Code Online (Sandbox Code Playgroud) 如何让RequestMapping处理url中的GET参数?例如,我有这个网址
http://localhost:8080/userGrid?_search=false&nd=1351972571018&rows=10&page=1&sidx=id&sord=desc
Run Code Online (Sandbox Code Playgroud)
(来自jqGrid)
我的RequestMapping应该怎么样?我想使用HttpReqest获取参数
试过这个:
@RequestMapping("/userGrid")
public @ResponseBody GridModel getUsersForGrid(HttpServletRequest request)
Run Code Online (Sandbox Code Playgroud)
但它不起作用.
我按照这个样本进行Spring Batch with Boot.
运行main方法时,将执行作业.这样我就无法弄清楚如何控制作业执行.例如,您如何安排作业,或访问作业执行或设置作业参数.
我试着注册我自己的JobLauncher
@Bean
public JobLauncher jobLauncher(JobRepository jobRepo){
SimpleJobLauncher simpleJobLauncher = new SimpleJobLauncher();
simpleJobLauncher.setJobRepository(jobRepo);
return simpleJobLauncher;
}
Run Code Online (Sandbox Code Playgroud)
但是当我尝试在main方法中使用它时:
public static void main(String[] args) {
ConfigurableApplicationContext ctx = SpringApplication.run(Application.class, args);
JobLauncher jobLauncher = ctx.getBean(JobLauncher.class);
//try catch removed for readability
jobLauncher.run(ctx.getBean(Job.class), new JobParameters());
}
Run Code Online (Sandbox Code Playgroud)
加载上下文后再次执行作业,JobInstanceAlreadyCompleteException
当我尝试手动运行时,我得到了该作业.有没有办法阻止自动执行作业?
据我所知,当你想在Spring Security中进行自定义身份验证时,你可以实现自定义AuthenticationProvider
或自定义UserDetailsService
.
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth
//.authenticationProvider(authProvider) // option 1
.userDetailsService(userDetailsService); // option 2
}
Run Code Online (Sandbox Code Playgroud)
在AuthenticationProvider中,您可以检查用户名和密码,并返回Authentication
其中的自定义对象.
public Authentication authenticate(Authentication authentication){
if (checkUsernameAndPassword(authentication)) {
CustomUserDetails userDetails = new CustomUserDetails();
//add whatever you want to the custom user details object
return new UsernamePasswordAuthenticationToken(userDetails, password, grantedAuths);
} else {
throw new BadCredentialsException("Unable to auth against third party systems");
}
}
Run Code Online (Sandbox Code Playgroud)
在UserDetailsService
您只获取用户名时,当您返回自定义UserDeatails时,框架会检查密码.
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
CustomUserDetails user …
Run Code Online (Sandbox Code Playgroud) 在Web应用程序(jsp/servlets)中获取EntityManagerFactory的最佳方法是什么?这是一个好方法何时应该创建/打开EntityManagerFactory实例?或者从JNDI或其他东西获得它更好吗?
我有一个数据表如下:
<h:dataTable value="#{bean.items}" var="item">
Run Code Online (Sandbox Code Playgroud)
我想用从服务方法获得的数据库中的集合填充它,以便在初始(GET)请求期间打开页面时立即显示它.我什么时候应该打电话给服务方法?为什么?
我以前使用Eclipse Galileo,但现在我有Helios.Galileo曾经自动添加我的servlet web.xml
,但是在Helios我自己必须这样做.
我可以配置一些东西让它再次自动化吗?
我正在尝试将DAO注入托管属性.
public class UserInfoBean {
private User user;
@ManagedProperty("#{userDAO}")
private UserDAO dao;
public UserInfoBean() {
this.user = dao.getUserByEmail("test@gmail.com");
}
// Getters and setters.
}
Run Code Online (Sandbox Code Playgroud)
在创建bean之后注入DAO对象,但它null
在构造函数中并因此导致NullPointerException
.如何使用注入的托管属性初始化托管bean?
jsf constructor nullpointerexception managed-bean managed-property
我想使用JQuery的Sortable(http://jqueryui.com/sortable/#connect-lists),所以我的左边列表将以这样的结尾
<ul>
<li>
Some txt1
<input type="hidden" name="li1" value="1"/>
</li>
<li>
Some txt2
<input type="hidden" name="li2" value="2"/>
</li>
</ul>
Run Code Online (Sandbox Code Playgroud)
<li>
每次的数量都不同.我的想法是将所有隐藏的输入值和名称放在数组中并将数组作为JSON数据发布,但我的Controller应该如何?有没有办法"等待"控制器中的某些内容列表.例如:
@RequestMapping(value = "/listItems")
public @ResponseBody GridModel getUsersForGrid(@RequestParam(value = "items") List<NameIdPair> items){...}
Run Code Online (Sandbox Code Playgroud) Spring和Java EE对websockets提供了很好的支持.例如在Spring中,您可以:
@Configuration
@EnableWebSocket
public class WebSocketConfig implements WebSocketConfigurer {
@Override
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
registry.addHandler(new MyHandler(), "/myHandler")
.addInterceptors(new HttpSessionHandshakeInterceptor());
}
}
Run Code Online (Sandbox Code Playgroud)
通过MyHandler
类,您可以发送和侦听HTML5 websocket的消息.
var webSocket =
new WebSocket('ws://localhost:8080/myHandler');
webSocket.onmessage = function(event) {
onMessage(event)
};
Run Code Online (Sandbox Code Playgroud)
问题是如果您在负载均衡器后面运行多个服务器.服务器A的客户端不会收到服务器B上的事件通知.
Spring中使用带有Stomp协议的消息代理解决了这个问题(http://assets.spring.io/wp/WebSocketBlogPost.html)
由于使用处理程序和"本机"html5 websockets对我来说更容易,然后是Stomp方式,我的问题是:
java ×6
spring ×5
spring-mvc ×3
javascript ×2
jsf ×2
angular ×1
automation ×1
constructor ×1
datatable ×1
eclipse ×1
getter ×1
html5 ×1
jndi ×1
jpa ×1
jquery ×1
loading ×1
managed-bean ×1
servlets ×1
spring-batch ×1
spring-boot ×1
typescript ×1
websocket ×1