我使用angularjs,我创建了一个正常的输入字段,如下所示:
<input type="text" style="border: none" ng-model="model" >
Run Code Online (Sandbox Code Playgroud)
我想要做以下事情:
如果有人在输入字段中单击,我想调用示例方法A.然后他在此字段中写入文本,如果该人在页面中的某处单击以便输入字段不再聚焦,则应调用方法B.这是可能的与angularjs?如果是的话,我该怎么做?ng-focus仅在输入事件处激活,但不在输出处激活.
我希望锁定一些东西,方法A只设置一个值为true,方法B将相同的值设置为false.但我必须知道输入字段何时处于活动状态,何时不处于活动状
我使用Spring MVC(4.0.1)作为休息服务的后端和angularjs作为前端.
对我的服务器后端的每个请求都有一个带有会话ID的http-header
我可以使用以下代码在服务器后端读取此标头:
@Autowired
protected HttpServletRequest request;
String xHeader=request.getHeader("X-Auth-Token"); //returns the sessionID from the header
Run Code Online (Sandbox Code Playgroud)
现在我调用此方法getPermission(xHeader)只返回true或false.如果用户存在于我的数据库中,则返回true,否则为false!
我现在想要创建一个具有此行为的过滤器,如果用户有权访问我的控制器,则会检查每个请求!但是如果该方法返回false,它应该发回401错误而不能到达我的控制器!
我该怎么做并创建自己的过滤器?我只使用Java Config而不使用XML.
我想我必须在这里添加过滤器:
public class WebInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {
@Override
protected Filter[] getServletFilters() {
MyOwnFilter=new MyOwnFilter();
return new Filter[] {MyOwnFilter};
}
}
Run Code Online (Sandbox Code Playgroud) 我已经使用Spring配置了java MV,我已经定义了一些休息服务.我使用Spring作为服务器后端,使用AngularJS作为WebFrontend.
我想从我的AngularJS网站上传一个或两个CSV文件到我的休息服务.我如何使用java配置配置spring以使其工作?我使用了Tomcat和一个Servlet 3容器.
我的上传休息服务如下所示:
@Controller
@RequestMapping("Upload")
@MultipartConfig(fileSizeThreshold=1024*1024*10, // 10 MB
maxFileSize=1024*1024*50, // 50 MB
maxRequestSize=1024*1024*100) // 100 MB
public class UploadController {
@RequestMapping(value="/upload", method=RequestMethod.GET)
public @ResponseBody String provideUploadInfo() {
return "You can upload a file by posting to this same URL.";
}
@RequestMapping(value="/upload", method=RequestMethod.POST)
public @ResponseBody String handleFileUpload(@RequestParam("name") String name,
@RequestParam("file") MultipartFile file){
if (!file.isEmpty()) {
try {
byte[] bytes = file.getBytes();
BufferedOutputStream stream =
new BufferedOutputStream(new FileOutputStream(new File(name + "-uploaded")));
stream.write(bytes);
stream.close();
return "You successfully uploaded " + …Run Code Online (Sandbox Code Playgroud)