问:
Thymeleaf & Spring @RequestParam: cannot pass a field value to the url
I want to use the search field value in order to perform a search.

This is my html form:

```<code><form th:action="@{../service/search}" method="get">
  <input type="text" th:name="${searchParameter}" class="form-control" />
  <button type="submit" class="btn btn-success">Search</button>
</form>
</code>```

And this is my controller method:

```<code>@GetMapping("/firm/search")
    public String searchFirms (@RequestParam(value = "searchParameter", required = true) String query,
                               Map <String, Object> model,
                               HttpServletRequest servletRequest,
                               HttpServletResponse servletResponse,
                               HttpSession httpSession) throws IOException {

        log.info("Request to search Firms for query {}", query);
        model.put(VERSION, applicationVersion);
        Cookie cookie = authService.findCookie(servletRequest, servletResponse);
        HttpHeaders httpHeaders = authService.createJwtAuthHeader(cookie);
        HttpEntity requestEntity = new HttpEntity(httpHeaders);
        ResponseEntity <UserObject> userObjectResponse = authService.createUserResponseEntity(requestEntity, servletResponse);
        authService.setUserSessionDetails(userObjectResponse, httpSession);

        ...
    }
</code>```

When I click the submit button, I get the url in the browser: http://localhost:8011/services/service/search? but it should be http://localhost:8011/services/service/search?query=searchparameter and a 404 error.

This is the exception:

```<code>org.springframework.expression.spel.SpelEvaluationException: EL1011E: Method call: Attempted to call method getAttribute(java.lang.String) on null context object
    at org.springframework.expression.spel.ast.MethodReference.throwIfNotNullSafe(MethodReference.java:144) ~[spring-expression-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.springframework.expression.spel.ast.MethodReference.getValueRef(MethodReference.java:73) ~[spring-expression-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.springframework.expression.spel.ast.CompoundExpression.getValueRef(CompoundExpression.java:66) ~[spring-expression-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:87) ~[spring-expression-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.springframework.expression.spel.ast.SpelNodeImpl.getValue(SpelNodeImpl.java:120) ~[spring-expression-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:267) ~[spring-expression-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.thymeleaf.spring4.expression.SpelVariableExpressionEvaluator.evaluate(SpelVariableExpressionEvaluator.java:139) ~[thymeleaf-spring4-2.1.5.RELEASE.jar:2.1.5.RELEASE]
    at org.thymeleaf.standard.expression.VariableExpression.executeVariable(VariableExpression.java:154) ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE]
    at org.thymeleaf.standard.expression.SimpleExpression.executeSimple(SimpleExpression.java:59) ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE]
    at org.thymeleaf.standard.expression.Expression.execute(Expression.java:103) ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE]
    at org.thymeleaf.standard.expression.Expression.execute(Expression.java:133) ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE]
    at org.thymeleaf.standard.expression.EqualsExpression.executeEquals(EqualsExpression.java:66) ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE]
    at org.thymeleaf.standard.expression.ComplexExpression.executeComplex(ComplexExpression.java:88) ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE]
    at org.thymeleaf.standard.expression.Expression.execute(Expression.java:107) ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE]
    at org.thymeleaf.standard.expression.Expression.execute(Expression.java:133) ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE]
    at org.thymeleaf.standard.expression.Expression.execute(Expression.java:120) ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE]
    at org.thymeleaf.standard.processor.attr.AbstractStandardConditionalVisibilityAttrProcessor.isVisible(AbstractStandardConditionalVisibilityAttrProcessor.java:66) ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE]
    at org.thymeleaf.processor.attr.AbstractConditionalVisibilityAttrProcessor.processAttribute(AbstractConditionalVisibilityAttrProcessor.java:59) ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE]
    at org.thymeleaf.processor.attr.AbstractAttrProcessor.doProcess(AbstractAttrProcessor.java:87) ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE]
    at org.thymeleaf.processor.AbstractProcessor.process(AbstractProcessor.java:212) ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE]
    at org.thymeleaf.dom.Node.applyNextProcessor(Node.java:1017) ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE]
    at org.thymeleaf.dom.Node.processNode(Node.java:972) ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE]
    at org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:695) ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE]
    at org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:668) ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE]
    at org.thymeleaf.dom.Node.processNode(Node.java:990) ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE]
    at org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:695) ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE]
    at org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:668) ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE]
    at org.thymeleaf.dom.Node.processNode(Node.java:990) ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE]
    at org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:695) ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE]
    at org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:668) ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE]
    at org.thymeleaf.dom.Node.processNode(Node.java:990) ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE]
    at org.thymeleaf.dom.Document.process(Document.java:93) ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE]
    at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1155) ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE]
    at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1060) ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE]
    at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1011) ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE]
    at org.thymeleaf.spring4.view.ThymeleafView.renderFragment(ThymeleafView.java:335) ~[thymeleaf-spring4-2.1.5.RELEASE.jar:2.1.5.RELEASE]
    at org.thymeleaf.spring4.view.ThymeleafView.render(ThymeleafView.java:190) ~[thymeleaf-spring4-2.1.5.RELEASE.jar:2.1.5.RELEASE]
    at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1282) ~[spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1037) ~[spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:980) ~[spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897) ~[spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970) ~[spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861) ~[spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:622) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846) ~[spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:726) [tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:471) [tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:394) [tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:311) [tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.catalina.core.StandardHostValve.custom(StandardHostValve.java:395) [tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.catalina.core.StandardHostValve.status(StandardHostValve.java:254) [tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:177) [tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) [tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) [tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349) [tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:783) [tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) [tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:798) [tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1434) [tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-8.5.11.jar:8.5.11]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_91]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_91]
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-8.5.11.jar:8.5.11]
    at java.lang.Thread.run(Thread.java:745) [na:1.8.0_91]
</code>```

答:
Change your input tag as shown below:</p>

```<code><form th:action="@{../service/search}" method="get">
  <input type="text" name="query" th:value="${searchParameter}" class="form-control" />
  <button type="submit" class="btn btn-success">Search</button>
</form>
</code>```

Body:
I want to use the search field value in order to perform a search.

This is my html form:

<form th:action="@{../service/search}" method="get">
  <input type="text" th:name="${searchParameter}" class="form-control" />
  <button type="submit" class="btn btn-success">Search</button>
</form>

And this is my controller method:

@GetMapping("/firm/search")
    public String searchFirms (@RequestParam(value = "searchParameter", required = true) String query,
                               Map <String, Object> model,
                               HttpServletRequest servletRequest,
                               HttpServletResponse servletResponse,
                               HttpSession httpSession) throws IOException {

        log.info("Request to search Firms for query {}", query);
        model.put(VERSION, applicationVersion);
        Cookie cookie = authService.findCookie(servletRequest, servletResponse);
        HttpHeaders httpHeaders = authService.createJwtAuthHeader(cookie);
        HttpEntity requestEntity = new HttpEntity(httpHeaders);
        ResponseEntity <UserObject> userObjectResponse = authService.createUserResponseEntity(requestEntity, servletResponse);
        authService.setUserSessionDetails(userObjectResponse, httpSession);

        ...
    }

When I click the submit button, I get the url in the browser: http://localhost:8011/services/service/search? but it should be http://localhost:8011/services/service/search?query=searchparameter and a 404 error.

This is the exception:

org.springframework.expression.spel.SpelEvaluationException: EL1011E: Method call: Attempted to call method getAttribute(java.lang.String) on null context object
    at org.springframework.expression.spel.ast.MethodReference.throwIfNotNullSafe(MethodReference.java:144) ~[spring-expression-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.springframework.expression.spel.ast.MethodReference.getValueRef(MethodReference.java:73) ~[spring-expression-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.springframework.expression.spel.ast.CompoundExpression.getValueRef(CompoundExpression.java:66) ~[spring-expression-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:87) ~[spring-expression-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.springframework.expression.spel.ast.SpelNodeImpl.getValue(SpelNodeImpl.java:120) ~[spring-expression-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:267) ~[spring-expression-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.thymeleaf.spring4.expression.SpelVariableExpressionEvaluator.evaluate(SpelVariableExpressionEvaluator.java:139) ~[thymeleaf-spring4-2.1.5.RELEASE.jar:2.1.5.RELEASE]
    at org.thymeleaf.standard.expression.VariableExpression.executeVariable(VariableExpression.java:154) ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE]
    at org.thymeleaf.standard.expression.SimpleExpression.executeSimple(SimpleExpression.java:59) ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE]
    at org.thymeleaf.standard.expression.Expression.execute(Expression.java:103) ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE]
    at org.thymeleaf.standard.expression.Expression.execute(Expression.java:133) ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE]
    at org.thymeleaf.standard.expression.EqualsExpression.executeEquals(EqualsExpression.java:66) ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE]
    at org.thymeleaf.standard.expression.ComplexExpression.executeComplex(ComplexExpression.java:88) ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE]
    at org.thymeleaf.standard.expression.Expression.execute(Expression.java:107) ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE]
    at org.thymeleaf.standard.expression.Expression.execute(Expression.java:133) ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE]
    at org.thymeleaf.standard.expression.Expression.execute(Expression.java:120) ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE]
    at org.thymeleaf.standard.processor.attr.AbstractStandardConditionalVisibilityAttrProcessor.isVisible(AbstractStandardConditionalVisibilityAttrProcessor.java:66) ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE]
    at org.thymeleaf.processor.attr.AbstractConditionalVisibilityAttrProcessor.processAttribute(AbstractConditionalVisibilityAttrProcessor.java:59) ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE]
    at org.thymeleaf.processor.attr.AbstractAttrProcessor.doProcess(AbstractAttrProcessor.java:87) ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE]
    at org.thymeleaf.processor.AbstractProcessor.process(AbstractProcessor.java:212) ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE]
    at org.thymeleaf.dom.Node.applyNextProcessor(Node.java:1017) ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE]
    at org.thymeleaf.dom.Node.processNode(Node.java:972) ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE]
    at org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:695) ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE]
    at org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:668) ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE]
    at org.thymeleaf.dom.Node.processNode(Node.java:990) ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE]
    at org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:695) ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE]
    at org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:668) ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE]
    at org.thymeleaf.dom.Node.processNode(Node.java:990) ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE]
    at org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:695) ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE]
    at org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:668) ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE]
    at org.thymeleaf.dom.Node.processNode(Node.java:990) ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE]
    at org.thymeleaf.dom.Document.process(Document.java:93) ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE]
    at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1155) ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE]
    at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1060) ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE]
    at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1011) ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE]
    at org.thymeleaf.spring4.view.ThymeleafView.renderFragment(ThymeleafView.java:335) ~[thymeleaf-spring4-2.1.5.RELEASE.jar:2.1.5.RELEASE]
    at org.thymeleaf.spring4.view.ThymeleafView.render(ThymeleafView.java:190) ~[thymeleaf-spring4-2.1.5.RELEASE.jar:2.1.5.RELEASE]
    at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1282) ~[spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1037) ~[spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:980) ~[spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897) ~[spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970) ~[spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861) ~[spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:622) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846) ~[spring-webmvc-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:726) [tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:471) [tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:394) [tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:311) [tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.catalina.core.StandardHostValve.custom(StandardHostValve.java:395) [tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.catalina.core.StandardHostValve.status(StandardHostValve.java:254) [tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:177) [tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) [tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) [tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349) [tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:783) [tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) [tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:798) [tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1434) [tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-8.5.11.jar:8.5.11]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_91]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_91]
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-8.5.11.jar:8.5.11]
    at java.lang.Thread.run(Thread.java:745) [na:1.8.0_91]

Body:
Change your input tag as shown below:

<form th:action="@{../service/search}" method="get">
  <input type="text" name="query" th:value="${searchParameter}" class="form-control" />
  <button type="submit" class="btn btn-success">Search</button>
</form>


来源: stackexchange

问:
MySQL-Can we use range for text which has numbers?
In the table 'DailyStatus' one the column value text is like 'taskRead2017ww23.3','taskWrite2017ww45.5', etc

That means all the column values has year and work week as string.

How can I get the data if we want as work week ranges.?

For ex. I want all records in the ranges between 2017ww23.3 to 2017ww25.4

I tried with RLIKE and '|' but i need to pass every single work week value to the query like below

```<code>select *
  from dailystatus
 where taskname rlike '.*(*ww23.3 |*ww23.4 | *ww23.3 | .......|25.4 )'
</code>```

The above method seems very difficult if the range increases.

Is there any optimized way to achieve this?

答:
If I understand correctly, you can take the last 10 characters from the string and use that for the comparison:</p>

```<code>select ds.*
from dailystatus ds
where right(ds.taskname, 10) between '2017ww23.3' and '2017ww25.4';
</code>```

ContentLicense: CC BY-SA 3.0

Body:
In the table 'DailyStatus' one the column value text is like 'taskRead2017ww23.3','taskWrite2017ww45.5', etc

That means all the column values has year and work week as string.

How can I get the data if we want as work week ranges.?

For ex. I want all records in the ranges between 2017ww23.3 to 2017ww25.4

I tried with RLIKE and '|' but i need to pass every single work week value to the query like below

select *
  from dailystatus
 where taskname rlike '.*(*ww23.3 |*ww23.4 | *ww23.3 | .......|25.4 )'

The above method seems very difficult if the range increases.

Is there any optimized way to achieve this?

Body:
If I understand correctly, you can take the last 10 characters from the string and use that for the comparison:

select ds.*
from dailystatus ds
where right(ds.taskname, 10) between '2017ww23.3' and '2017ww25.4';


问:
Grouped UITableView with multiple sections creating problem in iPhone SDK
In my iPhone app, I am having a grouped table view. I have used viewForHeaderInSection method to change the font color and size of font of section headers.

I have 4 sections in the tableview.

Problem

If there is no data in Section 0 and section 1 then too Section 2 starts to display in table somewhere near center of the view instead of top of the screen.

I want that when section 0 and section 1 cells are empty the section 2 should come at the top of the view as if it is section 0.

How should I proceed?

答:
for this purpose,

you need to check weather data exist or not suppose you display data from array so,check

([array count]>0)

check this according to you and now,when you return the number of section then you cant

return 4;[hard code].

dynamically check data then according to condition return the number of section.

ContentLicense: CC BY-SA 4.0

ContentLicense: CC BY-SA 2.5


问:
Will my SSL certificate work for new Wordpress website on IIS?
I have an IIS running on the server and a website (.net) running perfectly on http (80) and https (443). And i have a new Wordpress website. I wanna publish the wordpress site on the same domain. In order to do it i will remove the files of the present website and place the new site's files and in theory,i expect IIS will start to show this new site. And all the bindings and everything s set on IIS for this SSL certificate for the same domain. So my question is , can i expect that new site will run perfectly on http (80) and https (443)? Or will https fail?</p>

答: Well in theory it supposed to work but it didn t. Eventually  i figured that SSL certificate was revoked. </p>


问:
Sonar raises blocker issue on java FileSystems.getDefault()
I have this below code statement,

```<code>this.watchService = FileSystems.getDefault().newWatchService();
</code>```

Sonar(sonarqube 5.6.4) raises a blocker issue in the FileSystems.getDefault() part of the above code, stating this,

Resources should be closed - Java's garbage collection cannot be
  relied on to clean up everything. Specifically, connections, streams,
  files and other classes that implement the Closeable interface or it's
  super-interface, AutoCloseable, must be manually closed after
  creation. Failure to do so will result in a resource leak which could
  bring first the application and then perhaps the box it's on to their
  knees.

And then, i checked the javadoc for FileSystem which says,

File systems created by the default provider cannot be closed.

Reference -> https://docs.oracle.com/javase/7/docs/api/java/nio/file/FileSystem.html

Now my problem is how to solve this sonar issue, without marking it ignore.
Please help if anyone has solved this.

答:
The simplest thing to do if you're sure of your case is to tell Sonar that what you have here is a false positive and that it should not be flagged.
You might also be able to use a try with resources construct, making Sonar think the resource is being closed when in fact it is not (if Java handles it correctly, it shouldn't try to close it when using a try with resources in this case).</p>

Body:
I have this below code statement,

this.watchService = FileSystems.getDefault().newWatchService();

Sonar(sonarqube 5.6.4) raises a blocker issue in the FileSystems.getDefault() part of the above code, stating this,

Resources should be closed - Java's garbage collection cannot be
  relied on to clean up everything. Specifically, connections, streams,
  files and other classes that implement the Closeable interface or it's
  super-interface, AutoCloseable, must be manually closed after
  creation. Failure to do so will result in a resource leak which could
  bring first the application and then perhaps the box it's on to their
  knees.

And then, i checked the javadoc for FileSystem which says,

File systems created by the default provider cannot be closed.

Reference -> https://docs.oracle.com/javase/7/docs/api/java/nio/file/FileSystem.html

Now my problem is how to solve this sonar issue, without marking it ignore.
Please help if anyone has solved this.


问:
Phonegap - load external URL in webview not working in release mode apk
I am trying to load external URL in PhoneGap webview using the below mentioned code in my index.html deviceIsReady():

```<code>window.open('https://google.com', '_self ', 'location=yes');
</code>```

and in config.xml:

```<code><content src="index.html" />
<allow-navigation href="https://google.com/*" />
</code>```

The above URL works fine when the code is run using PhoneGap desktop app and viewed in Android mobile using Phonegap Adnroid app.

But when the same code is build in release mode using an .apk generated from PhoneGap cloud and run on Android device by enabling Unknown source option in device settings, a blank page is displayed without any error message.

Think I am missing some permission? Can anyone help me in resolving this issue?

答:
Since I was trying to load a external URL in webview I had to include below plugin which I forgot to include earlier:

<plugin name="cordova-plugin-inappbrowser">

Body:
I am trying to load external URL in PhoneGap webview using the below mentioned code in my index.html deviceIsReady():

window.open('https://google.com', '_self ', 'location=yes');

and in config.xml:

<content src="index.html" />
<allow-navigation href="https://google.com/*" />

The above URL works fine when the code is run using PhoneGap desktop app and viewed in Android mobile using Phonegap Adnroid app.

But when the same code is build in release mode using an .apk generated from PhoneGap cloud and run on Android device by enabling Unknown source option in device settings, a blank page is displayed without any error message.

Think I am missing some permission? Can anyone help me in resolving this issue?


问:
Angular - Select inside ng-repeat
I have a problem with selects inside ng-repeat, the problem is that every select I create inside a ng-repeat are disabled, if I try to open the dropdown it doesn't show the options.

Select are generated in ng-repeat and the number of selects and all values are
in a JSON.

I think the problem could be the selects's ng-model, i must assign dynamically an ng-model but i don't know how.

This is the code (i don't include the service that get the JSON, but it works for sure)

JSON

```<code>[
   {
      "Id":1,
      "Name":"Tipo Fuga",
      "Values":[
         {
            "Name":"Tipo Fuga",
            "Value":"Week End in Famiglia",
            "Id":10555
         },
         {
            "Name":"Tipo Fuga",
            "Value":"Fuga romantica",
            "Id":10560
         }
      ]
   },
   {
      "Id":2,
      "Name":"Localita",
      "Values":[
         {
            "Name":"Localita",
            "Value":"Al mare",
            "Id":111
         },
         {
            "Name":"Localita",
            "Value":"In montagna",
            "Id":112
         }
      ]
   },
   {
      "Id":3,
      "Name":"Num Notti",
      "Values":[
         {
            "Name":"Num Notti",
            "Value":"1",
            "Id":11076
         },
         {
            "Name":"Num Notti",
            "Value":"2",
            "Id":11077
         }
      ]
   },
   {
      "Id":4,
      "Name":"Tipo Soggiorno",
      "Values":[
         {
            "Name":"Tipo Soggiorno",
            "Value":"1 stella",
            "Id":1100
         },
         {
            "Name":"Tipo Soggiorno",
            "Value":"2 stelle",
            "Id":1101
         }
      ]
   }
]
</code>```

HTML

```<code><div ng-controller="ricercaAttivita">
    <div ng-repeat="masterAttribute in masterAttributes">
        <select ng-model="selected-attr" ng-options="attr.Id as attr.Value for attr in masterAttribute.Values">
        </select>
    </div>
</div>
</code>```

CONTROLLER

```<code>tantoSvagoApp.controller("ricercaAttivita", function ($scope, $http, serviceRicercaAttivita) {

    var parametersMaster = {"Id": master};
    serviceRicercaAttivita.getMasterAttributes(parametersMaster,
    successCallBackMasterAttributes);

    function successCallBackMasterAttributes(result) {
            $scope.masterAttributes = result;
    }
});
</code>```

EDIT

I tried to do a simple thing, i created a select with static options inside a div and of course it works fine:

```<code><div>
  <select>
    <option value="">TUTTE</option>
    <option value="1">1</option>
    <option value="2">2</option>
    <option value="3">3</option>
    <option value="4">4</option>
    <option value="5">5</option>
  </select>
</div>
</code>```

If i put the ng-repeat directive in the  select doesn't work, it mean that i can't open the dropdown and then select the option.

```<code><div ng-repeat="masterAttribute in masterAttributes">
  <select>
    <option value="">TUTTE</option>
    <option value="1">1</option>
    <option value="2">2</option>
    <option value="3">3</option>
    <option value="4">4</option>
    <option value="5">5</option>
  </select>
</div>
</code>```

答:
The problem statement seems ambiguous.

ng-model can be a new property in the JSON which holds the selected id from the select.

var app = angular.module("MyApp", []);
app.controller("ricercaAttivita", function($scope) {
  $scope.masterAttributes = [{
      "Id": 1,
      "Name": "Tipo Fuga",
      "Values": [{
          "Name": "Tipo Fuga",
          "Value": "Week End in Famiglia",
          "Id": 10555
        },
        {
          "Name": "Tipo Fuga",
          "Value": "Fuga romantica",
          "Id": 10560
        }
      ]
    },
    {
      "Id": 2,
      "Name": "Localita",
      "Values": [{
          "Name": "Localita",
          "Value": "Al mare",
          "Id": 111
        },
        {
          "Name": "Localita",
          "Value": "In montagna",
          "Id": 112
        }
      ]
    },
    {
      "Id": 3,
      "Name": "Num Notti",
      "Values": [{
          "Name": "Num Notti",
          "Value": "1",
          "Id": 11076
        },
        {
          "Name": "Num Notti",
          "Value": "2",
          "Id": 11077
        }
      ]
    },
    {
      "Id": 4,
      "Name": "Tipo Soggiorno",
      "Values": [{
          "Name": "Tipo Soggiorno",
          "Value": "1 stella",
          "Id": 1100
        },
        {
          "Name": "Tipo Soggiorno",
          "Value": "2 stelle",
          "Id": 1101
        }
      ]
    }
  ];
});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>

<body ng-app="MyApp" ng-controller="ricercaAttivita">
  <div ng-repeat="masterAttribute in masterAttributes">
    <select ng-model="masterAttribute.Selected" ng-options="attr.Id as attr.Value for attr in masterAttribute.Values">
        </select>
  </div>
  ```{{masterAttributes | json}}```

</body></code>```

Title: Angular - Select inside ng-repeat

Body:
I have a problem with selects inside ng-repeat, the problem is that every select I create inside a ng-repeat are disabled, if I try to open the dropdown it doesn't show the options.

Select are generated in ng-repeat and the number of selects and all values are
in a JSON.

I think the problem could be the selects's ng-model, i must assign dynamically an ng-model but i don't know how.

This is the code (i don't include the service that get the JSON, but it works for sure)

JSON

[
   {
      "Id":1,
      "Name":"Tipo Fuga",
      "Values":[
         {
            "Name":"Tipo Fuga",
            "Value":"Week End in Famiglia",
            "Id":10555
         },
         {
            "Name":"Tipo Fuga",
            "Value":"Fuga romantica",
            "Id":10560
         }
      ]
   },
   {
      "Id":2,
      "Name":"Localita",
      "Values":[
         {
            "Name":"Localita",
            "Value":"Al mare",
            "Id":111
         },
         {
            "Name":"Localita",
            "Value":"In montagna",
            "Id":112
         }
      ]
   },
   {
      "Id":3,
      "Name":"Num Notti",
      "Values":[
         {
            "Name":"Num Notti",
            "Value":"1",
            "Id":11076
         },
         {
            "Name":"Num Notti",
            "Value":"2",
            "Id":11077
         }
      ]
   },
   {
      "Id":4,
      "Name":"Tipo Soggiorno",
      "Values":[
         {
            "Name":"Tipo Soggiorno",
            "Value":"1 stella",
            "Id":1100
         },
         {
            "Name":"Tipo Soggiorno",
            "Value":"2 stelle",
            "Id":1101
         }
      ]
   }
]

HTML

        <select ng-model="selected-attr" ng-options="attr.Id as attr.Value for attr in masterAttribute.Values">
        </select>

CONTROLLER

tantoSvagoApp.controller("ricercaAttivita", function ($scope, $http, serviceRicercaAttivita) {

    var parametersMaster = {"Id": master};
    serviceRicercaAttivita.getMasterAttributes(parametersMaster,
    successCallBackMasterAttributes);

    function successCallBackMasterAttributes(result) {
            $scope.masterAttributes = result;
    }
});

EDIT

I tried to do a simple thing, i created a select with static options inside a div and of course it works fine:

  <select>
    <option value="">TUTTE</option>
    <option value="1">1</option>
    <option value="2">2</option>
    <option value="3">3</option>
    <option value="4">4</option>
    <option value="5">5</option>
  </select>

If i put the ng-repeat directive in the  select doesn't work, it mean that i can't open the dropdown and then select the option.

  <select>
    <option value="">TUTTE</option>
    <option value="1">1</option>
    <option value="2">2</option>
    <option value="3">3</option>
    <option value="4">4</option>
    <option value="5">5</option>
  </select>

Body:
The problem statement seems ambiguous.

ng-model can be a new property in the JSON which holds the selected id from the select.

var app = angular.module("MyApp", []);
app.controller("ricercaAttivita", function($scope) {
  $scope.masterAttributes = [{
      "Id": 1,
      "Name": "Tipo Fuga",
      "Values": [{
          "Name": "Tipo Fuga",
          "Value": "Week End in Famiglia",
          "Id": 10555
        },
        {
          "Name": "Tipo Fuga",
          "Value": "Fuga romantica",
          "Id": 10560
        }
      ]
    },
    {
      "Id": 2,
      "Name": "Localita",
      "Values": [{
          "Name": "Localita",
          "Value": "Al mare",
          "Id": 111
        },
        {
          "Name": "Localita",
          "Value": "In montagna",
          "Id": 112
        }
      ]
    },
    {
      "Id": 3,
      "Name": "Num Notti",
      "Values": [{
          "Name": "Num Notti",
          "Value": "1",
          "Id": 11076
        },
        {
          "Name": "Num Notti",
          "Value": "2",
          "Id": 11077
        }
      ]
    },
    {
      "Id": 4,
      "Name": "Tipo Soggiorno",
      "Values": [{
          "Name": "Tipo Soggiorno",
          "Value": "1 stella",
          "Id": 1100
        },
        {
          "Name": "Tipo Soggiorno",
          "Value": "2 stelle",
          "Id": 1101
        }
      ]
    }
  ];
});

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>

<body ng-app="MyApp" ng-controller="ricercaAttivita">
  <div ng-repeat="masterAttribute in masterAttributes">
    <select ng-model="masterAttribute.Selected" ng-options="attr.Id as attr.Value for attr in masterAttribute.Values">
        </select>
  </div>
  <pre>{{masterAttributes | json}}</pre>

</body>


问:
C# - Conversion while calling method with output parameter
Disclaimer: Not a professional developer

We're using SSIS to pull messages RabbitMQ, and I've managed to build a C# script component that pulls and pops messages off our queue for us using Queue.Dequeue(). So far, so good. However, we want to have some form of automatic check in place so our SSIS component won't be running continuously, but rather can be scheduled to run every n minutes.

I found the Dequeue(int timeout, out object result) method for this, and have managed to implement it like so: (we'd like the BasiocDeliverEventArgs result in order to process the body of the message)

```<code>object message;
myConsumer.Queue.Dequeue(millisecondsTimeout: 500, result:out message);
BasicDeliverEventArgs ea = (BasicDeliverEventArgs)message;
</code>```

This seems to work, but somehow feel somewhat redundant to me. This, for example, seems more intuitive to me:

```<code>myConsumer.Queue.Dequeue(millisecondsTimeout: 500
     , result:out (BasicDeliverEventArgs)message)
</code>```

But that yields an error specifying invalid arguments. Could someone please explain why it would throw that error, and why that syntax is invalid?

答:
You can't do this:

```<code>myConsumer.Queue.Dequeue(millisecondsTimeout: 500
 , result:out (BasicDeliverEventArgs)message)
</code>```

because the Dequeue method is allowed to assign any object to the message parameter - it could be a "string", etc - which would lead to VeryBadThings™.

So no: you can't do that.

Body:
Disclaimer: Not a professional developer

We're using SSIS to pull messages RabbitMQ, and I've managed to build a C# script component that pulls and pops messages off our queue for us using Queue.Dequeue(). So far, so good. However, we want to have some form of automatic check in place so our SSIS component won't be running continuously, but rather can be scheduled to run every n minutes.

I found the Dequeue(int timeout, out object result) method for this, and have managed to implement it like so: (we'd like the BasiocDeliverEventArgs result in order to process the body of the message)

object message;
myConsumer.Queue.Dequeue(millisecondsTimeout: 500, result:out message);
BasicDeliverEventArgs ea = (BasicDeliverEventArgs)message;

This seems to work, but somehow feel somewhat redundant to me. This, for example, seems more intuitive to me:

myConsumer.Queue.Dequeue(millisecondsTimeout: 500
     , result:out (BasicDeliverEventArgs)message)

But that yields an error specifying invalid arguments. Could someone please explain why it would throw that error, and why that syntax is invalid?

Body:
You can't do this:

myConsumer.Queue.Dequeue(millisecondsTimeout: 500
 , result:out (BasicDeliverEventArgs)message)

because the Dequeue method is allowed to assign any object to the message parameter - it could be a "string", etc - which would lead to VeryBadThings™.

So no: you can't do that.


问:
Best way to add a cross browser hover to a div
How can I add a simple hover to a div that will be compatible with FF, IE7+ and chrome?

All I need is a simple text hover, and I am pretty sure that you can set it as a property of an HTML element but I cant seem to find it anywhere.

答: You're probably looking for the title attribute.  This generally renders like a tooltip.


问:
Paragraph tag closes itself when opened
I'm working on a news section for my website and when using the following code:

```<code><p id="news-container">
  <h1> . . . </h1>
  <strong>big</strong> . . . .
</p>
</code>```

When inspecting issues I'm getting, it seems to parse as:

```<code><p id="news-container"></p>
  . . . same stuff
<p></p>
</code>```

There are no extra paragraph tags inside of the parent ones, and no extra parsing is done using PHP since when inspecting the page source it looks exactly as it should be, but when are element inspecting it's parsed that way, any thoughts?

PS: I tried putting the whole paragraph tags in one set but that didn't fix the issue.

PPS: I'm using SCSS as my CSS compiler, that couldn't mess with the paragraphs though?

答:
 Shouldn't really be a parent element except for  and other text formatting  tags.

Sometimes browsers (such as Chrome) will close the paragraph when they render it if another element is opened within it.

Title: Paragraph tag closes itself when opened

Body:
I'm working on a news section for my website and when using the following code:

 . . .

  big . . . .

When inspecting issues I'm getting, it seems to parse as:

  . . . same stuff

There are no extra paragraph tags inside of the parent ones, and no extra parsing is done using PHP since when inspecting the page source it looks exactly as it should be, but when are element inspecting it's parsed that way, any thoughts?

PS: I tried putting the whole paragraph tags in one set but that didn't fix the issue.

PPS: I'm using SCSS as my CSS compiler, that couldn't mess with the paragraphs though?

Body:
<p> Shouldn't really be a parent element except for <span> and other text formatting  tags.

Sometimes browsers (such as Chrome) will close the paragraph when they render it if another element is opened within it.


问:
two-way binding on checkbox ngFor Angular2
I am creating an Angular2 project and having a problem with two-way binding for a checkbox.

I have a class called listItem and List like that:

```<code>export class ListItem {
  public count: number;
  public value: string;
  public checked: boolean;

  constructor(count: number, value: string, checked: boolean) {
    this.count = count;
    this.value = value;
    this.checked = checked;
  }
}

export class MyList{
  public category: string;
  public listItem : ListItem [];

  constructor(category: string, listItem : ListItem []) {
    this.category = category;
    this.listItem = listItem ;
  }
}
</code>```

and I am calling the list from Azure search which is working correctly.
the problem is when I just set the value to a checkbox.

```<code><div *ngFor="let list of myList; let listIndex = index;">
  <div *ngFor="let item of list.listItems; let itemIndex = index;">
    <input type="checkbox" [name]="list.category + item.value"
         (change)="item.checked = !item.checked"
         [ngModel]="item.checked" />
  </div
</div>
</code>```

but the value is always false also onClick. I tried to use [(ngModel)] but did not work also.
I also tried to make a function:

```<code>(change)="oncheck(listIndex, itemIndex)"

oncheck(listIndex: number, itemIndex: number) {
   this.myList[listIndex].listItems[itemIndex].checked =
           !this.myList[listIndex].listItems[itemIndex].checked;
  }
</code>```

but I received this error:

Cannot assign to read-only property 'checked' of object '[object
  Object]'

why is that and how to fix it? thank you

答:
You could use the material2 md-checkbox directive to create styled elements.
In my opinion that is not really two-way binding, its just a combination of 1 way binding in both directions (template - data source and data source - template)

UPDATE:
I created a small plnkr to reproduce your situation: http://plnkr.co/edit/cr7TokiqSaBGli7mgCBM

```<code>@Component({
  selector: 'my-app',
  template: `
    <div *ngFor="let element of elements; let i = index;">
    <span>Val: {{element}}</span>
      <input type="checkbox"
       [checked]="element" (change)="handleChange(element, i)">
    </div>
  `,
})
export class App {
  elements= [
    false,
    true,
    false,
  ]:

  handleChange(val: boolean, index: number){
    console.log("Index: "+index);
    console.log("Val:  "+val);
    this.elements[index] = !val;
  }
</code>```

The elements in the list are correctly rendered, but the change events will in some cases modify the values of incorrect positions in the elements array. Ill take a furhter look later

UPDATE: refactored plnkr

Please check:
http://plnkr.co/edit/Ich0g5kzSiQINZjh3VYo

I made some changes to the plnkr that u sent me.

I changed the iteration variables from const to let (considering that their values arent constant during execution of the loops).

As I mentioned before, most likely there are 2 posibilities: the classes in .ts are being transpiled in a wrong way to .js (class members are being setted as readonly by default), or there is something wrong in the way that you are manually mapping the values to class instances.

Body:
I am creating an Angular2 project and having a problem with two-way binding for a checkbox.

I have a class called listItem and List like that:

export class ListItem {
  public count: number;
  public value: string;
  public checked: boolean;

  constructor(count: number, value: string, checked: boolean) {
    this.count = count;
    this.value = value;
    this.checked = checked;
  }
}

export class MyList{
  public category: string;
  public listItem : ListItem [];

  constructor(category: string, listItem : ListItem []) {
    this.category = category;
    this.listItem = listItem ;
  }
}

and I am calling the list from Azure search which is working correctly.
the problem is when I just set the value to a checkbox.

    <input type="checkbox" [name]="list.category + item.value"
         (change)="item.checked = !item.checked"
         [ngModel]="item.checked" />
  </div

but the value is always false also onClick. I tried to use [(ngModel)] but did not work also.
I also tried to make a function:

(change)="oncheck(listIndex, itemIndex)"

oncheck(listIndex: number, itemIndex: number) {
   this.myList[listIndex].listItems[itemIndex].checked =
           !this.myList[listIndex].listItems[itemIndex].checked;
  }

but I received this error:

Cannot assign to read-only property 'checked' of object '[object
  Object]'

why is that and how to fix it? thank you

Body:
You could use the material2 md-checkbox directive to create styled elements.
In my opinion that is not really two-way binding, its just a combination of 1 way binding in both directions (template - data source and data source - template)

UPDATE:
I created a small plnkr to reproduce your situation: http://plnkr.co/edit/cr7TokiqSaBGli7mgCBM

@Component({
  selector: 'my-app',
  template: `
    <div *ngFor="let element of elements; let i = index;">
    <span>Val: {{element}}</span>
      <input type="checkbox"
       [checked]="element" (change)="handleChange(element, i)">
    </div>
  `,
})
export class App {
  elements= [
    false,
    true,
    false,
  ]:

  handleChange(val: boolean, index: number){
    console.log("Index: "+index);
    console.log("Val:  "+val);
    this.elements[index] = !val;
  }

The elements in the list are correctly rendered, but the change events will in some cases modify the values of incorrect positions in the elements array. Ill take a furhter look later

UPDATE: refactored plnkr

Please check:
http://plnkr.co/edit/Ich0g5kzSiQINZjh3VYo

I made some changes to the plnkr that u sent me.

I changed the iteration variables from const to let (considering that their values arent constant during execution of the loops).

As I mentioned before, most likely there are 2 posibilities: the classes in .ts are being transpiled in a wrong way to .js (class members are being setted as readonly by default), or there is something wrong in the way that you are manually mapping the values to class instances.


答:
Paragraph tag closes itself when opened

No.

The paragraph is closed when the
 start tag is encountered.

It is forbidden to have a heading inside a paragraph, and the end tag for paragraphs is optional.

See the specification and pay particular attention to the "Content model" and "Tag omission in text/html" sections.

Your content looks more like a , a
 or an
 than it does a
.

Title: Paragraph tag closes itself when opened

Body:
Paragraph tag closes itself when opened

No.

The paragraph is closed when the <h1> start tag is encountered.

It is forbidden to have a heading inside a paragraph, and the end tag for paragraphs is optional.

See the specification and pay particular attention to the "Content model" and "Tag omission in text/html" sections.

Your content looks more like a <header>, a <section> or an <article> than it does a <p>.


答:
Paragraphs are block level and are automatically closed by the browser's parser when it encounters another block-level element (the H1 in this case).

What you see in the inspector is the empty paragraph getting closed.

Title: Paragraph tag closes itself when opened


问:
Android new Intent with back button
In my Android App I use an empty activity with one button. If I push the button I call a new activity with an intent. But on the new activity the back button (top left) to jump back to the last page is missing. Isn't there already a activity template from android studio or a spezial intent call to do this? Or what is the best way to do this?

This is the function which is called on the button press

```<code>void scanClicked(View v){
    Intent intent = new Intent(this, ServiceActivity.class);
    startActivity(intent);
}
</code>```

The ServiceActivity is just an Empty Activity

```<code>    <activity
        android:name=".LoginActivity"
        android:label="@string/title_activity_login"
        android:theme="@style/SplashTheme"
        android:windowSoftInputMode="adjustPan">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name=".NavigationActivity"
        android:label="@string/title_activity_navigation"
        android:theme="@style/AppTheme.NoActionBar" />
    <activity android:name=".ServiceActivity"
        android:label="@string/annualServiceTitle">
    </activity>
</code>```

答:
You need to use setDisplayHomeAsUpEnabled in your ServiceActivity.java like this:

```<code>public class ServiceActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // etc...
        getActionBar().setDisplayHomeAsUpEnabled(true);
    }
...
}
</code>```

Title: Android new Intent with back button

Body:
In my Android App I use an empty activity with one button. If I push the button I call a new activity with an intent. But on the new activity the back button (top left) to jump back to the last page is missing. Isn't there already a activity template from android studio or a spezial intent call to do this? Or what is the best way to do this?

This is the function which is called on the button press

void scanClicked(View v){
    Intent intent = new Intent(this, ServiceActivity.class);
    startActivity(intent);
}

The ServiceActivity is just an Empty Activity

    <activity
        android:name=".LoginActivity"
        android:label="@string/title_activity_login"
        android:theme="@style/SplashTheme"
        android:windowSoftInputMode="adjustPan">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name=".NavigationActivity"
        android:label="@string/title_activity_navigation"
        android:theme="@style/AppTheme.NoActionBar" />
    <activity android:name=".ServiceActivity"
        android:label="@string/annualServiceTitle">
    </activity>

Body:
You need to use setDisplayHomeAsUpEnabled in your ServiceActivity.java like this:

public class ServiceActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // etc...
        getActionBar().setDisplayHomeAsUpEnabled(true);
    }
...
}


答:
Try this

On the activity you want to move to ServiceActivity call intent by

```<code>Intent intent = new Intent(this, ServiceActivity.class);
startActivity(intent);
</code>```

And on the ServiceActivity handle the click event and call

```<code>view.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
        supportFinishAfterTransition();
        // or call
        finish();
    }
});
</code>```

Title: Android new Intent with back button

Body:
Try this

On the activity you want to move to ServiceActivity call intent by

Intent intent = new Intent(this, ServiceActivity.class);
startActivity(intent);

And on the ServiceActivity handle the click event and call

view.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
        supportFinishAfterTransition();
        // or call
        finish();
    }
});


问:
How to implement QTextDocument serialization
This question I have asked before and just got answer that there is an open bug for this. But this is a really required feature and, I guess, each Qt programmer who programmes a more or less serious application, it is quite probable that there is used a QTextEdit and the data is inserted in QTextEdit is serialized and deserialized. Thus I consider this issue very importand and it can be useful for many Qt developers. So I have decided to discuss with good programmers how to implement operator<<(QDataStream, QTextDocument). Otherwise we should wait when Qt guys will be kind to do that by themselves :).

So say in a QTextEdit I have some pictures and text. In different fragments the text has different format. How to get the content of this kind of QTextEdit and how to serialize, in order to show then as it was?

EDIT: I know that I can get the formated text and images by using documnet() method, which returns QTextDocument. I also know that QTextDocument has no operator<<(QDataStream, QTextDocument) and there is a request for writting this operator but it is still open. So please help me to write this method.
I guess I should inherit the QTextDocument class, then to add a new member (a container) that stores all the names of resources that are present in the QTextEdit. Then I should serialize all resources by iterating on them by using the container I have defined. Is it a good solution? If yes, then could you please help me to implement? If no then please provide me with a better idea.

答:
See here:

How to serialize and deserialize rich text in QTextEdit?


问:
constructor threw exception nested exception is java.lang.nullpointerexception
Hi following is the scenario

```<code>@Component
public class DateFormatter() {

public String DateToString() {
   //some Logic;
      }
    }

public class DataProvider{

@Resource("dateFormatter")
private DateFormatter dateFormatter;

public void test(){
  Date date = new Date();

    String formattedDate = this.dateFormatter(date);

  system.out.print("Formatted Date is :" + formattedDate);}
}
</code>```

constructor threw exception nested exception is java.lang.nullpointerexception is what i see on my console

答:
this.dateFormatter(date); is calling DateFormatter and dateFormatter and it do not have method like this becouse dateFormatter in your example is not a method.

```<code>public String DateToString(Date date) {
    //some Logic;
    return "";
}
</code>```

You can not call DateToString method with date in parameter and do not provide it in method declaration.

```<code>public class DataProvider{

        private DateFormatter dateFormatter;

        public void test(){
            Date date = new Date();

            DateFormatter dateFormatter = new DateFormatter();
            String formattedDate = dateFormatter.DateToString(date);

            System.out.print("Formatted Date is :" + formattedDate);}
    }
</code>```

Or you can do something like this:
public class DataProvider{

```<code>    private DateFormatter dateFormatter;

    public DataProvider(DateFormatter dateFormatter) {
        this.dateFormatter = dateFormatter;
    }

    public void test(){
        Date date = new Date();

        String formattedDate = dateFormatter.DateToString(date);

        System.out.print("Formatted Date is :" + formattedDate);}
}
</code>```

You have to create instance of a Object to call a method.

Body:
Hi following is the scenario

@Component
public class DateFormatter() {

public String DateToString() {
   //some Logic;
      }
    }

public class DataProvider{

@Resource("dateFormatter")
private DateFormatter dateFormatter;

public void test(){
  Date date = new Date();

    String formattedDate = this.dateFormatter(date);

  system.out.print("Formatted Date is :" + formattedDate);}
}

constructor threw exception nested exception is java.lang.nullpointerexception is what i see on my console

Body:
this.dateFormatter(date); is calling DateFormatter and dateFormatter and it do not have method like this becouse dateFormatter in your example is not a method.

public String DateToString(Date date) {
    //some Logic;
    return "";
}

You can not call DateToString method with date in parameter and do not provide it in method declaration.

public class DataProvider{

        private DateFormatter dateFormatter;

        public void test(){
            Date date = new Date();

            DateFormatter dateFormatter = new DateFormatter();
            String formattedDate = dateFormatter.DateToString(date);

            System.out.print("Formatted Date is :" + formattedDate);}
    }

Or you can do something like this:
public class DataProvider{

    private DateFormatter dateFormatter;

    public DataProvider(DateFormatter dateFormatter) {
        this.dateFormatter = dateFormatter;
    }

    public void test(){
        Date date = new Date();

        String formattedDate = dateFormatter.DateToString(date);

        System.out.print("Formatted Date is :" + formattedDate);}
}

You have to create instance of a Object to call a method.


问:
How to create, with Odoo 8, a list of most purchased products on customer profile?
I want to generate a list (tree) that shows the most purchased products with extra data (product, quantity of orders, total of units purchased, total amount, date of last purchase, average of days between purchases).

I supose I should create a new class, process the data and associate it res_partner. I don't have idea about how to implement this: Should be a stored model? Can I process this data without store the result?

I hope you can help me!

答:
You can Create On Screen Report For that.

```<code>from openerp import fields,api,models
from openerp import tools

class on_screen_report(models.Model):
  _name = "on.screen.report"
  _description = "On Screen Report"
  _auto = False

  """
  Needed fields.
  """

  def init(self, cr):
     tools.drop_view_if_exists(cr, self._table)
     _query = """ create or replace view on_screen_report as(
       select
       min(sol.id) as id
       //Further query to get data.
       )
       """

  def search(self, cr, uid, args, offset=0, limit=None, order=None,context=None, count=False):
      return super(on_screen_report, self).search(cr, uid, args=args, offset=offset, limit=limit, order=order,
  context=context, count=count)

  sale_analysis_report_ept()
</code>```

For query you need to create same view as your model name.
So, it will store output of the query in that table.
When we create tree view of this model it will execute this query and get all the data.

Body:
You can Create On Screen Report For that.

from openerp import fields,api,models
from openerp import tools

class on_screen_report(models.Model):
  _name = "on.screen.report"
  _description = "On Screen Report"
  _auto = False

  """
  Needed fields.
  """

  def init(self, cr):
     tools.drop_view_if_exists(cr, self._table)
     _query = """ create or replace view on_screen_report as(
       select
       min(sol.id) as id
       //Further query to get data.
       )
       """

  def search(self, cr, uid, args, offset=0, limit=None, order=None,context=None, count=False):
      return super(on_screen_report, self).search(cr, uid, args=args, offset=offset, limit=limit, order=order,
  context=context, count=count)

  sale_analysis_report_ept()

For query you need to create same view as your model name.
So, it will store output of the query in that table.
When we create tree view of this model it will execute this query and get all the data.


问:
SSRS The permissions are insufficient for performing this operation
I am new to SSRS and deployed my first report with it.  When deploying the report, I added access to the site for the user group DOMAIN\user-group with the "System User' role under Site Settings > Security.  I also added the group to the home folder with the browser role and ensured all folders and items inherit parent settings.  The report is running with a service account with SA permissions to the DB it is reading from.

When I run the report locally or remotely as myself then I am able to run it, however whenever a member of the domain group tries to run it they get the below error message:

An error has occurred during report processing.
(rsProcessingAborted)

The permissions granted to user 'DOMAIN\user' are insufficient for performing this operation. (rsAccessDenied)

答:
Even though the problem above got resolved, I am adding my answer just in case someone else would come across this issue in the future.

Had the same error message, but after many trials of playing with SQL securities, it appeared as if the SSRS folders didn't have the security level required. Added an Admin security level, and the problem was resolved.


问:
how can I redirect to https which require certain sertificate for access
There's a payment server. I can successfully send data via cURL and set appropriate key and certificate and payment server successfully answers. But now I need to make a redirect to that server so that client can enter credit card data. How can I make that redirect?

Is there a possibility to add key/certificate as a part of headers in function header("Location: https://...."); ?

答:
Even if you could send the certificate along with the redirect, the browser still has to verify it. But you can't. It's impossible. You have to send a regular redirect. Because it's a https address, the browser will first request the certificate from the target host and verify it (including necessary user intervention). The outcome is the same.

There is no way to circumvent the popup dialog requesting the user to accept/trust or deny the certificate. HTTPS is designed to ensure "reasonable protection from eavesdroppers and man-in-the-middle attacks, provided that adequate cipher suites are used and that the server certificate is verified and trusted." (Quote from Wikipedia)


问:
How to find the Exact Class/ID selector in Bootstrap CSS file to Override in Custom made CSS file
Sorry, I know this question looks silly. But I'm having trouble with finding the exact ID selectors to override those functions in my custom made css file

Can anyone please tell me what is the best way to find the exact ID which perform the relevant function (eg: changing background color, font color, hover background) in bootstrap css file so I can override those functions in my own custom made css file.

As an example, I have this code sample copied from bootstrap.css
and think I need to change the  color of the hover when I mouse over the drop down list.

```<code><!--This is the original code I copied-->

            <ul class="nav navbar-nav">
                <li class="active"><a href="#">Home<span class="sr-only">(current)</span></a></li>
                <li><a href="#">About Us</a></li>
                <li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Our Softwares <span class="caret"></span></a>
                    <ul class="dropdown-menu">
                        <li><a href="#">Software 1</a></li>
                        <li><a href="#">Software 2</a></li>
                        <li><a href="#">Software 3</a></li>
                        <!--<li role="separator" class="divider"></li>
                        <li><a href="#">Separated link</a></li>
                        <li role="separator" class="divider"></li>
                        <li><a href="#">One more separated link</a></li>-->
                    </ul>
                </li>
            </ul>
</code>```

So There is a dropdown list I have created (Software 1, Software 2, Software 3). I need to Change the color of Hover (When I put my mouse over any option available in Drop Down list).  According to the flow of the above code is it possible achieve that using these steps?

nav navbar-nav -> dropdown -> dropdown-toggle -> dropdown-menu

If I go in dropdown-menu in bootstrap.css I can see these code samples:

1)

```<code>@media (max-width: 767px) {
  .navbar-default .navbar-nav .open .dropdown-menu > li > a {
    color: #777;
  }
  .navbar-default .navbar-nav .open .dropdown-menu > li > a:hover,
  .navbar-default .navbar-nav .open .dropdown-menu > li > a:focus {
    color: #333;
    background-color: transparent;
  }
  .navbar-default .navbar-nav .open .dropdown-menu > .active > a,
  .navbar-default .navbar-nav .open .dropdown-menu > .active > a:hover,
  .navbar-default .navbar-nav .open .dropdown-menu > .active > a:focus {
    color: #555;
    background-color: #e7e7e7;
  }
  .navbar-default .navbar-nav .open .dropdown-menu > .disabled > a,
  .navbar-default .navbar-nav .open .dropdown-menu > .disabled > a:hover,
  .navbar-default .navbar-nav .open .dropdown-menu > .disabled > a:focus {
    color: #ccc;
    background-color: transparent;
  }
}
</code>```

2)

```<code>  @media (max-width: 767px) {
  .navbar-inverse .navbar-nav .open .dropdown-menu > .dropdown-header {
    border-color: #080808;
  }
  .navbar-inverse .navbar-nav .open .dropdown-menu .divider {
    background-color: #080808;
  }
  .navbar-inverse .navbar-nav .open .dropdown-menu > li > a {
    color: #9d9d9d;
  }
  .navbar-inverse .navbar-nav .open .dropdown-menu > li > a:hover,
  .navbar-inverse .navbar-nav .open .dropdown-menu > li > a:focus {
    color: #fff;
    background-color: transparent;
  }
  .navbar-inverse .navbar-nav .open .dropdown-menu > .active > a,
  .navbar-inverse .navbar-nav .open .dropdown-menu > .active > a:hover,
  .navbar-inverse .navbar-nav .open .dropdown-menu > .active > a:focus {
    color: #fff;
    background-color: #080808;
  }
  .navbar-inverse .navbar-nav .open .dropdown-menu > .disabled > a,
  .navbar-inverse .navbar-nav .open .dropdown-menu > .disabled > a:hover,
  .navbar-inverse .navbar-nav .open .dropdown-menu > .disabled > a:focus {
    color: #444;
    background-color: transparent;
  }
}
</code>```

3)

```<code>navbar-nav > li > .dropdown-menu {
  margin-top: 0;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}
.navbar-fixed-bottom .navbar-nav > li > .dropdown-menu {
  margin-bottom: 0;
  border-top-left-radius: 4px;
  border-top-right-radius: 4px;
  border-bottom-right-radius: 0;
  border-bottom-left-radius: 0;
}
</code>```

4)

```<code>  @media (max-width: 767px) {
  .navbar-nav .open .dropdown-menu {
    position: static;
    float: none;
    width: auto;
    margin-top: 0;
    background-color: transparent;
    border: 0;
    -webkit-box-shadow: none;
            box-shadow: none;
  }
  .navbar-nav .open .dropdown-menu > li > a,
  .navbar-nav .open .dropdown-menu .dropdown-header {
    padding: 5px 15px 5px 25px;
  }
  .navbar-nav .open .dropdown-menu > li > a {
    line-height: 20px;
  }
  .navbar-nav .open .dropdown-menu > li > a:hover,
  .navbar-nav .open .dropdown-menu > li > a:focus {
    background-image: none;
  }
}
</code>```

And out of these 4 code samples I posted above, what is the EXACT location where I can change the hovering color of my Drop Down List?

And please explain your answer in a simple way so I can understand it. I'm really exhausted looking into those code samples to find the exact location.

Thank you very much!

答:
Here you go:

.navbar-nav .open .dropdown-menu>li>a:hover {
  background-color: blue;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<ul class="nav navbar-nav">
  <li class="active">Home<span class="sr-only">(current)</span></li>
  <li>About Us</li>
  <li class="dropdown">
    Our Softwares <span class="caret"></span>
    <ul class="dropdown-menu">
      <li>Software 1</li>
      <li>Software 2</li>
      <li>Software 3</li>
      <!--<li role="separator" class="divider"></li>
                        <li>Separated link</li>
                        <li role="separator" class="divider"></li>
                        <li>One more separated link</li>-->
    </ul>
  </li>
</ul></code>```

Body:
Sorry, I know this question looks silly. But I'm having trouble with finding the exact ID selectors to override those functions in my custom made css file

Can anyone please tell me what is the best way to find the exact ID which perform the relevant function (eg: changing background color, font color, hover background) in bootstrap css file so I can override those functions in my own custom made css file.

As an example, I have this code sample copied from bootstrap.css
and think I need to change the  color of the hover when I mouse over the drop down list.

Home(current)

About Us

                    Our Softwares

Software 1

Software 2

Software 3

So There is a dropdown list I have created (Software 1, Software 2, Software 3). I need to Change the color of Hover (When I put my mouse over any option available in Drop Down list).  According to the flow of the above code is it possible achieve that using these steps?

nav navbar-nav -> dropdown -> dropdown-toggle -> dropdown-menu

If I go in dropdown-menu in bootstrap.css I can see these code samples:

1)

@media (max-width: 767px) {
  .navbar-default .navbar-nav .open .dropdown-menu > li > a {
    color: #777;
  }
  .navbar-default .navbar-nav .open .dropdown-menu > li > a:hover,
  .navbar-default .navbar-nav .open .dropdown-menu > li > a:focus {
    color: #333;
    background-color: transparent;
  }
  .navbar-default .navbar-nav .open .dropdown-menu > .active > a,
  .navbar-default .navbar-nav .open .dropdown-menu > .active > a:hover,
  .navbar-default .navbar-nav .open .dropdown-menu > .active > a:focus {
    color: #555;
    background-color: #e7e7e7;
  }
  .navbar-default .navbar-nav .open .dropdown-menu > .disabled > a,
  .navbar-default .navbar-nav .open .dropdown-menu > .disabled > a:hover,
  .navbar-default .navbar-nav .open .dropdown-menu > .disabled > a:focus {
    color: #ccc;
    background-color: transparent;
  }
}

2)

  @media (max-width: 767px) {
  .navbar-inverse .navbar-nav .open .dropdown-menu > .dropdown-header {
    border-color: #080808;
  }
  .navbar-inverse .navbar-nav .open .dropdown-menu .divider {
    background-color: #080808;
  }
  .navbar-inverse .navbar-nav .open .dropdown-menu > li > a {
    color: #9d9d9d;
  }
  .navbar-inverse .navbar-nav .open .dropdown-menu > li > a:hover,
  .navbar-inverse .navbar-nav .open .dropdown-menu > li > a:focus {
    color: #fff;
    background-color: transparent;
  }
  .navbar-inverse .navbar-nav .open .dropdown-menu > .active > a,
  .navbar-inverse .navbar-nav .open .dropdown-menu > .active > a:hover,
  .navbar-inverse .navbar-nav .open .dropdown-menu > .active > a:focus {
    color: #fff;
    background-color: #080808;
  }
  .navbar-inverse .navbar-nav .open .dropdown-menu > .disabled > a,
  .navbar-inverse .navbar-nav .open .dropdown-menu > .disabled > a:hover,
  .navbar-inverse .navbar-nav .open .dropdown-menu > .disabled > a:focus {
    color: #444;
    background-color: transparent;
  }
}

3)

navbar-nav > li > .dropdown-menu {
  margin-top: 0;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}
.navbar-fixed-bottom .navbar-nav > li > .dropdown-menu {
  margin-bottom: 0;
  border-top-left-radius: 4px;
  border-top-right-radius: 4px;
  border-bottom-right-radius: 0;
  border-bottom-left-radius: 0;
}

4)

  @media (max-width: 767px) {
  .navbar-nav .open .dropdown-menu {
    position: static;
    float: none;
    width: auto;
    margin-top: 0;
    background-color: transparent;
    border: 0;
    -webkit-box-shadow: none;
            box-shadow: none;
  }
  .navbar-nav .open .dropdown-menu > li > a,
  .navbar-nav .open .dropdown-menu .dropdown-header {
    padding: 5px 15px 5px 25px;
  }
  .navbar-nav .open .dropdown-menu > li > a {
    line-height: 20px;
  }
  .navbar-nav .open .dropdown-menu > li > a:hover,
  .navbar-nav .open .dropdown-menu > li > a:focus {
    background-image: none;
  }
}

And out of these 4 code samples I posted above, what is the EXACT location where I can change the hovering color of my Drop Down List?

And please explain your answer in a simple way so I can understand it. I'm really exhausted looking into those code samples to find the exact location.

Thank you very much!

Body:
Here you go:

.navbar-nav .open .dropdown-menu>li>a:hover {
  background-color: blue;
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<ul class="nav navbar-nav">
  <li class="active"><a href="#">Home<span class="sr-only">(current)</span></a></li>
  <li><a href="#">About Us</a></li>
  <li class="dropdown">
    <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Our Softwares <span class="caret"></span></a>
    <ul class="dropdown-menu">
      <li><a href="#">Software 1</a></li>
      <li><a href="#">Software 2</a></li>
      <li><a href="#">Software 3</a></li>
      <!--<li role="separator" class="divider"></li>
                        <li><a href="#">Separated link</a></li>
                        <li role="separator" class="divider"></li>
                        <li><a href="#">One more separated link</a></li>-->
    </ul>
  </li>
</ul>


问:
Limit choices to foreignkey in django rest framework
How to limit images of request.user to be linked with node. I wish I could do something like:

```<code>photo = models.ForeignKey(
    Image,
    limit_choices_to={'owner': username},
)
</code>```

but request.user rather than username and I don't want to use local threads.

models.py

```<code>class Node(models.Model):
    owner = models.ForeignKey(User)
    content = models.TextField()
    photo = models.ForeignKey(Image)

class Image(models.Model):
    owner = models.ForeignKey(User)
    file = models.ImageField(upload_to=get_upload_file_name)
</code>```

serializers.py

```<code>class ImageSerializer(serializers.ModelSerializer):
    owner = serializers.Field('owner.username')

    class Meta:
        model = Image
        fields = ('file', 'owner')

class NodeSerializer(serializers.HyperlinkedModelSerializer):

    class Meta:
        model = Node
        fields = ('content', 'photo', 'owner')
</code>```

答:
```<code>class CustomForeignKey(serializers.PrimaryKeyRelatedField):
    def get_queryset(self):
        return Table.objects.filter(is_active=True)

class Serializer(serializers.ModelSerializer):
    (...)
   table= CustomForeignKey()
   class Meta:
   (...)
</code>```

even more easy is :

```<code>class Serializer(serializers.ModelSerializer):
    (...)
    table = serializers.PrimaryKeyRelatedField(queryset=Table.objects.filter(is_active=True))
    class Meta:
    (...)
</code>```

Body:
How to limit images of request.user to be linked with node. I wish I could do something like:

photo = models.ForeignKey(
    Image,
    limit_choices_to={'owner': username},
)

but request.user rather than username and I don't want to use local threads.

models.py

class Node(models.Model):
    owner = models.ForeignKey(User)
    content = models.TextField()
    photo = models.ForeignKey(Image)

class Image(models.Model):
    owner = models.ForeignKey(User)
    file = models.ImageField(upload_to=get_upload_file_name)

serializers.py

class ImageSerializer(serializers.ModelSerializer):
    owner = serializers.Field('owner.username')

    class Meta:
        model = Image
        fields = ('file', 'owner')

class NodeSerializer(serializers.HyperlinkedModelSerializer):

    class Meta:
        model = Node
        fields = ('content', 'photo', 'owner')

Body:
class CustomForeignKey(serializers.PrimaryKeyRelatedField):
    def get_queryset(self):
        return Table.objects.filter(is_active=True)

class Serializer(serializers.ModelSerializer):
    (...)
   table= CustomForeignKey()
   class Meta:
   (...)

even more easy is :

class Serializer(serializers.ModelSerializer):
    (...)
    table = serializers.PrimaryKeyRelatedField(queryset=Table.objects.filter(is_active=True))
    class Meta:
    (...)


问:
MaxyBy return multiple item from the list
How can I return multiple item from the list that has the same value?
I am using maxBy to return item with the highest value on a property. Highest value is 5 and i know there are two items in the list with that. But it only returns 1 item back. I would like it to return both items.

itemA point = 5, itemB point = 5, itemC point = 4

```<code>var teamWithHighestPoint = _unsortedLeagueTable.MaxBy(t => t.Points);
</code>```

答:
Get all the elements with the maximum score:</p>

```<code>var maxPoints = _unsortedLeagueTable.Max(t => t.Points);
var teamWithHighestPoint = _unsortedLeagueTable.Where(t => t.Points == maxPoints);
</code>```

Body:
How can I return multiple item from the list that has the same value?
I am using maxBy to return item with the highest value on a property. Highest value is 5 and i know there are two items in the list with that. But it only returns 1 item back. I would like it to return both items.

itemA point = 5, itemB point = 5, itemC point = 4

var teamWithHighestPoint = _unsortedLeagueTable.MaxBy(t => t.Points);

Body:
Get all the elements with the maximum score:

var maxPoints = _unsortedLeagueTable.Max(t => t.Points);
var teamWithHighestPoint = _unsortedLeagueTable.Where(t => t.Points == maxPoints);


问:
Google Maps API v3: How to remove all markers?
In Google Maps API v2, if I wanted to remove all the map markers, I could simply do:

```<code>map.clearOverlays();
</code>```

How do I do this in Google Maps API v3?

Looking at the Reference API, it's unclear to me.

答:
Using this you can remove all marker from map .

```<code>map.clear();
</code>```

This would help you ,it help me..

Body:
In Google Maps API v2, if I wanted to remove all the map markers, I could simply do:

map.clearOverlays();

How do I do this in Google Maps API v3?

Looking at the Reference API, it's unclear to me.

Body:
Using this you can remove all marker from map .

map.clear();

This would help you ,it help me..


问:
Unable to send SMS before shutting down device
I'm developing an app which needs to send an SMS if / when the device shuts down.

In order to receive the action I'm using android.intent.action.ACTION_SHUTDOWN and android.intent.action.QUICKBOOT_POWEROFF actions, and it works perfectly well. In fact, the method I'm using to send the SMS is also working (as I have used it multiple times in other apps).

The problem I'm facing is that when I receive the SHUTDOWN action the telephony service is already off, so the SMS is unable to be sent and it remains queued waiting for a retry.

Is there a way to prevent / turning on again the telephony service in order to send my SMS?

In case it's not possible, is there another action similar to the SHUTDOWN event which I can use instead?

答:
Is there a way to prevent / turning on again the telephony service in order to send my SMS?

You are welcome to make your own customized build of Android that sends an SMS message as part of its shutdown process. Then, you can try to package that customized build of Android into a custom ROM for a particular piece of hardware.

If you are asking whether an app can do that on arbitrary hardware, the answer is no.

is there another action similar to the SHUTDOWN event which I can use instead?

You can ask the user to tap on something related to your app (e.g., a Notification) before shutting down the device.

Otherwise, I am not aware of some other event that not only tells you that the device is shutting down but also lets you block that shutdown process until you decide it is time to proceed (e.g., after sending an SMS, after forcing a ransomware payment).


问:
How do I go about adding inline form validation to this login page
How do I add inline validation to this page. Currently if there is an error it echos to a new page and you have to go back to the from. How do I do this automatically. I echo out my form, I'm not sure if this is good practise or not so any suggestions for improvements will be muchly appreciated.</p>

```<code>if(isset($_SESSION['signed_in']) && $_SESSION['signed_in'] == true)
{
    echo 'You are already signed in, you can <a href="Logour.php">sign out</a> if you want.';
}
else
{
    if($_SERVER['REQUEST_METHOD'] != 'POST')
    {
        /*the form hasn't been posted yet, display it
          note that the action="" will cause the form to post to the same page it is on */
            echo '
        <div class="container">
            <div id="login-form">
                <form method="post" action="">
                    <div classs="col-md-12">
                        <div class="form-group">
                            <h2>Sign Up</h2>
                        </div>
                        <div class="form-group">
                            <hr />
                        </div>

                        <div class="form-group">
                            <div class="input-group">
                                <span class="input-group-addon"><span class="glyphicon glyphicon-user"></span></span>
                                <input type="text" name="userName" class="form-control" placeholder="Enter username" maxlength="50"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="input-group">
                                <span class="input-group-addon"><span class="glyphicon glyphicon-lock"></span></span>
                                <input type="password" name="userPass" class="form-control" placeholder="Enter Password" maxlength="50"/>
                            </div>
                        </div>

                        <div class="form-group">
                            <hr />
                        </div>
                        <div class="form-group">
                            <button type="submit" class="btn btn-block btn-primary name="btn-signup">Sign In</button>
                        </div>
                        <div class="form-group">
                            <hr />
                        </div>
                        <div class="form-group">
                            <a href="Register.php">Register</a>
                        </div>
                    </div>
                </form>
            </div>
        </div>'
             ;
    }
    else
    {
        /* so, the form has been posted, we'll process the data in three steps:
            1.  Check the data
            2.  Let the user refill the wrong fields (if necessary)
            3.  Varify if the data is correct and return the correct response
        */
        $errors = array(); /* declare the array for later use */

        if(!isset($_POST['userName']))
        {
            $errors[] = 'The username field must not be empty.';
        }

        if(!isset($_POST['userPass']))
        {
            $errors[] = 'The password field must not be empty.';
        }
</code>```

答:
```<code>if(isset($_SESSION['signed_in']) && $_SESSION['signed_in'] == true)
{
    echo 'You are already signed in, you can <a href="Logour.php">sign out</a> if you want.';
}
else
{
if($_SERVER['REQUEST_METHOD'] != 'POST')
{
     /*the form hasn't been posted yet, display it
      note that the action="" will cause the form to post to the same page it is on */
?>
    <div class="container">
        <div id="login-form">
            <form method="post" action="">
                <div classs="col-md-12">
                    <div class="form-group">
                        <h2>Sign Up</h2>
                    </div>
                    <div class="form-group">
                        <hr />
                    </div>

                    <div class="form-group">
                        <div class="input-group">
                            <span class="input-group-addon"><span class="glyphicon glyphicon-user"></span></span>
                            <input type="text" name="userName" class="form-control" placeholder="Enter username" maxlength="50"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="input-group">
                            <span class="input-group-addon"><span class="glyphicon glyphicon-lock"></span></span>
                            <input type="password" name="userPass" class="form-control" placeholder="Enter Password" maxlength="50"/>
                        </div>
                    </div>

                    <div class="form-group">
                        <hr />
                    </div>
                    <div class="form-group">
                        <button type="submit" class="btn btn-block btn-primary name="btn-signup">Sign In</button>
                    </div>
                    <div class="form-group">
                        <hr />
                    </div>
                    <div class="form-group">
                        <a href="Register.php">Register</a>
                    </div>
                </div>
            </form>
        </div>
    </div>
<?php
}
else
{
    /* so, the form has been posted, we'll process the data in three steps:
        1.  Check the data
        2.  Let the user refill the wrong fields (if necessary)
        3.  Varify if the data is correct and return the correct response
    */
    $errors = array(); /* declare the array for later use */

    if(!isset($_POST['userName']))
    {
        $errors[] = 'The username field must not be empty.';
    }

    if(!isset($_POST['userPass']))
    {
        $errors[] = 'The password field must not be empty.';
    }
</code>```

Body:
How do I add inline validation to this page. Currently if there is an error it echos to a new page and you have to go back to the from. How do I do this automatically. I echo out my form, I'm not sure if this is good practise or not so any suggestions for improvements will be muchly appreciated.

if(isset($_SESSION['signed_in']) && $_SESSION['signed_in'] == true)
{
    echo 'You are already signed in, you can sign out if you want.';
}
else
{
    if($_SERVER['REQUEST_METHOD'] != 'POST')
    {
        /*the form hasn't been posted yet, display it
          note that the action="" will cause the form to post to the same page it is on */
            echo '

                <form method="post" action="">

Sign Up

                                <input type="text" name="userName" class="form-control" placeholder="Enter username" maxlength="50"/>

                                <input type="password" name="userPass" class="form-control" placeholder="Enter Password" maxlength="50"/>

                            <button type="submit" class="btn btn-block btn-primary name="btn-signup">Sign In</button>

                            Register

                </form>

'
             ;
    }
    else
    {
        /* so, the form has been posted, we'll process the data in three steps:
            1.  Check the data
            2.  Let the user refill the wrong fields (if necessary)
            3.  Varify if the data is correct and return the correct response
        */
        $errors = array(); /* declare the array for later use */

        if(!isset($_POST['userName']))
        {
            $errors[] = 'The username field must not be empty.';
        }

        if(!isset($_POST['userPass']))
        {
            $errors[] = 'The password field must not be empty.';
        }


问:
What is the form collection in asp.net/html?
Simple question but one i need to clarify for myself. In terms of collections that can be accessed in the request object there is:

```<code>Cookies:    (whats in  a text file in the browser)
Querystring:   (whats passed in the url like [key=value&key=value etc])
Server Variables:  ?
Form Variables:    ?
</code>```

The ones with the ? next to are the ones that I dont really understand where in the http packet/html they are placed. I did a capture using wireshark:

```<code>POST /Security/HelixSessionAuth.aspx HTTP/1.0
Content-Type: application/x-www-form-urlencoded
Content-Length: 391

ClientIP=192.168.20.31
Url=%2Fflash%2F56553550%5Fhi%2Emp4
Log=SESSIONSTART%20%5B13%2FDec%2F2010%3A16%3A31%3A23%20%2B0000%5D%20%20flash%2F56553550%5Fhi%2Emp4%200%20192%2E168%2E20%2E31%203%20%5B13%2FDec%2F2010%3A16%3A31%3A23%20%2B0000%5D%200%200%200%20%5B0%20No%20Error%5D%20%5B0%20No%20Error%5D%20%5Brtmp%3A%2F%2Fhelix%2Epete%2Evideolibraryserver%2Ecom%2Fflash%2F56553550%5Fhi%2Emp4%5D%0A
HTTP/1.1 404 Not Found
Content-Type: text/html; charset=us-ascii
Server: Microsoft-HTTPAPI/2.0
Date: Mon, 13 Dec 2010 16:31:23 GMT
Connection: close
Content-Length: 315

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD><TITLE>Not Found</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
<BODY><h2>Not Found</h2>
<hr><p>HTTP Error 404. The requested resource is not found.</p>
</BODY></HTML>
</code>```

Where abouts would they be in the above feed?

答: Wireshark for this is a bit of a sledgehammer-to-crack-a-nut, I'd suggest starting with the MSDN documentation for HttpRequest. This should help you understand what the Form and Server collections are and what they represent, then you'll know what you are looking for in the actual data packet.</p>

Body:
Simple question but one i need to clarify for myself. In terms of collections that can be accessed in the request object there is:

Cookies:    (whats in  a text file in the browser)
Querystring:   (whats passed in the url like [key=value&key=value etc])
Server Variables:  ?
Form Variables:    ?

The ones with the ? next to are the ones that I dont really understand where in the http packet/html they are placed. I did a capture using wireshark:

POST /Security/HelixSessionAuth.aspx HTTP/1.0
Content-Type: application/x-www-form-urlencoded
Content-Length: 391

ClientIP=192.168.20.31
Url=%2Fflash%2F56553550%5Fhi%2Emp4
Log=SESSIONSTART%20%5B13%2FDec%2F2010%3A16%3A31%3A23%20%2B0000%5D%20%20flash%2F56553550%5Fhi%2Emp4%200%20192%2E168%2E20%2E31%203%20%5B13%2FDec%2F2010%3A16%3A31%3A23%20%2B0000%5D%200%200%200%20%5B0%20No%20Error%5D%20%5B0%20No%20Error%5D%20%5Brtmp%3A%2F%2Fhelix%2Epete%2Evideolibraryserver%2Ecom%2Fflash%2F56553550%5Fhi%2Emp4%5D%0A
HTTP/1.1 404 Not Found
Content-Type: text/html; charset=us-ascii
Server: Microsoft-HTTPAPI/2.0
Date: Mon, 13 Dec 2010 16:31:23 GMT
Connection: close
Content-Length: 315

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<TITLE>Not Found</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii">

Not Found

HTTP Error 404. The requested resource is not found.

Where abouts would they be in the above feed?