问:
spring Bean creation exception Error creating bean with name
Hello all i am new to Spring please solve my problem i am getting bean creation exception here is my code(i created these in dynamic web project) i am trying to do a simple Springmvc project.

file name:  login.Jsp

```<code><form action="login.do" method="post">
username<input type="text" name="username"/>
password<input type="password" name="password"/>
<input type="submit" value="login"/>
</form>
</code>```

file name : web.xml

```<code><?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">

  <servlet>
  <servlet-name>loginapp</servlet-name>
  <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
  </servlet>
  <servlet-mapping>
  <servlet-name>loginapp</servlet-name>
  <url-pattern>*.do</url-pattern>
  </servlet-mapping>

</web-app>
</code>```

file name:loginapp-servlet.xml

```<code><?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd">
<beans>
        <bean id="id1" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
          <property name="mappings">
             <props>
                 <prop key="login.do">id2</prop>

        </props>
        </property>
        </bean>
        <bean id="id2" class="logincontroller"/>
</beans>
</code>```

file name : logincontroller.java

```<code>package springmvc;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

public class logincontroller implements Controller {

    @Override
    public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {

        String username = request.getParameter("username");
        String password = request.getParameter("password");
        loginaction action = new loginaction();
        String result = action.verifyuser(username,password);
        if(result.equals("success"))
        return new ModelAndView("success.jsp");
        else
            return new ModelAndView("failure.jsp");

    }

}
</code>```

filename : success.jsp

```<code><% out.println("login success");%>
</code>```

file name: failure.jsp

```<code><% out.println("failed");%>
</code>```

after i run login.jsp and typing username as "admin" password as "admin" i am getting this error

```<code>HTTP Status 500 - Servlet.init() for servlet loginapp threw exception

type Exception report

message Servlet.init() for servlet loginapp threw exception

description The server encountered an internal error that prevented it from fulfilling this request.

exception
javax.servlet.ServletException: Servlet.init() for servlet loginapp threw exception
    org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
    org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)
    org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:784)
    org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
    org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:802)
    org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1410)
    org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    java.lang.Thread.run(Unknown Source)

root cause
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'id1' defined in ServletContext resource [/WEB-INF/loginapp-servlet.xml]: Initialization of bean failed; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [logincontroller] for bean with name 'id2' defined in ServletContext resource [/WEB-INF/loginapp-servlet.xml]; nested exception is java.lang.ClassNotFoundException: logincontroller
Related cause: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [logincontroller] for bean with name 'id2' defined in ServletContext resource [/WEB-INF/loginapp-servlet.xml]; nested exception is java.lang.ClassNotFoundException: logincontroller
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:547)
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
    org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)
    org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
    org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
    org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
    org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:703)
    org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760)
    org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
    org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:658)
    org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:624)
    org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:672)
    org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:543)
    org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:484)
    org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)
    javax.servlet.GenericServlet.init(GenericServlet.java:158)
    org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
    org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)
    org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:784)
    org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
    org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:802)
    org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1410)
    org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    java.lang.Thread.run(Unknown Source)

root cause
org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [logincontroller] for bean with name 'id2' defined in ServletContext resource [/WEB-INF/loginapp-servlet.xml]; nested exception is java.lang.ClassNotFoundException: logincontroller
    org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1327)
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:594)
    org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1396)
    org.springframework.beans.factory.support.AbstractBeanFactory.isSingleton(AbstractBeanFactory.java:422)
    org.springframework.context.support.AbstractApplicationContext.isSingleton(AbstractApplicationContext.java:1002)
    org.springframework.web.servlet.handler.AbstractUrlHandlerMapping.registerHandler(AbstractUrlHandlerMapping.java:286)
    org.springframework.web.servlet.handler.SimpleUrlHandlerMapping.registerHandlers(SimpleUrlHandlerMapping.java:129)
    org.springframework.web.servlet.handler.SimpleUrlHandlerMapping.initApplicationContext(SimpleUrlHandlerMapping.java:104)
    org.springframework.context.support.ApplicationObjectSupport.initApplicationContext(ApplicationObjectSupport.java:120)
    org.springframework.web.context.support.WebApplicationObjectSupport.initApplicationContext(WebApplicationObjectSupport.java:73)
    org.springframework.context.support.ApplicationObjectSupport.setApplicationContext(ApplicationObjectSupport.java:74)
    org.springframework.context.support.ApplicationContextAwareProcessor.invokeAwareInterfaces(ApplicationContextAwareProcessor.java:119)
    org.springframework.context.support.ApplicationContextAwareProcessor.postProcessBeforeInitialization(ApplicationContextAwareProcessor.java:94)
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:407)
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1545)
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
    org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)
    org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
    org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
    org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
    org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:703)
    org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760)
    org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
    org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:658)
    org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:624)
    org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:672)
    org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:543)
    org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:484)
    org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)
    javax.servlet.GenericServlet.init(GenericServlet.java:158)
    org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
    org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)
    org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:784)
    org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
    org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:802)
    org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1410)
    org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    java.lang.Thread.run(Unknown Source)

root cause
java.lang.ClassNotFoundException: logincontroller
    org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1285)
    org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1119)
    org.springframework.util.ClassUtils.forName(ClassUtils.java:247)
    org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:395)
    org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.java:1348)
    org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1319)
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:594)
    org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1396)
    org.springframework.beans.factory.support.AbstractBeanFactory.isSingleton(AbstractBeanFactory.java:422)
    org.springframework.context.support.AbstractApplicationContext.isSingleton(AbstractApplicationContext.java:1002)
    org.springframework.web.servlet.handler.AbstractUrlHandlerMapping.registerHandler(AbstractUrlHandlerMapping.java:286)
    org.springframework.web.servlet.handler.SimpleUrlHandlerMapping.registerHandlers(SimpleUrlHandlerMapping.java:129)
    org.springframework.web.servlet.handler.SimpleUrlHandlerMapping.initApplicationContext(SimpleUrlHandlerMapping.java:104)
    org.springframework.context.support.ApplicationObjectSupport.initApplicationContext(ApplicationObjectSupport.java:120)
    org.springframework.web.context.support.WebApplicationObjectSupport.initApplicationContext(WebApplicationObjectSupport.java:73)
    org.springframework.context.support.ApplicationObjectSupport.setApplicationContext(ApplicationObjectSupport.java:74)
    org.springframework.context.support.ApplicationContextAwareProcessor.invokeAwareInterfaces(ApplicationContextAwareProcessor.java:119)
    org.springframework.context.support.ApplicationContextAwareProcessor.postProcessBeforeInitialization(ApplicationContextAwareProcessor.java:94)
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:407)
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1545)
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
    org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)
    org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
    org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
    org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
    org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:703)
    org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760)
    org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
    org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:658)
    org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:624)
    org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:672)
    org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:543)
    org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:484)
    org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)
    javax.servlet.GenericServlet.init(GenericServlet.java:158)
    org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
    org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)
    org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:784)
    org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
    org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:802)
    org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1410)
    org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    java.lang.Thread.run(Unknown Source)

note The full stack trace of the root cause is available in the Pivotal tc Runtime 3.2.2.RELEASE/8.5.6.B.RELEASE logs.

--------------------------------------------------------------------------------

Pivotal tc Runtime 3.2.2.RELEASE/8.5.6.B.RELEASE
</code>```

Here are the jar files i copied in lib folder :

```<code>commons-logging-1.2.jar
spring-aop-4.0.4.RELEASE.jar
spring-aop-4.0.4.RELEASE-javadoc.jar
spring-aop-4.0.4.RELEASE-sources.jar
spring-aspects-4.0.4.RELEASE.jar
spring-aspects-4.0.4.RELEASE-javadoc.jar
spring-aspects-4.0.4.RELEASE-sources.jar
spring-beans-4.0.4.RELEASE.jar
spring-beans-4.0.4.RELEASE-javadoc.jar
spring-beans-4.0.4.RELEASE-sources.jar
spring-build-src-4.0.4.RELEASE.jar
spring-context-4.0.4.RELEASE.jar
spring-context-4.0.4.RELEASE-javadoc.jar
spring-context-4.0.4.RELEASE-sources.jar
spring-context-support-4.0.4.RELEASE.jar
spring-context-support-4.0.4.RELEASE-javadoc.jar
spring-context-support-4.0.4.RELEASE-sources.jar
spring-core-4.0.4.RELEASE.jar
spring-core-4.0.4.RELEASE-javadoc.jar
spring-core-4.0.4.RELEASE-sources.jar
spring-expression-4.0.4.RELEASE.jar
spring-expression-4.0.4.RELEASE-javadoc.jar
spring-expression-4.0.4.RELEASE-sources.jar
spring-framework-bom-4.0.4.RELEASE.jar
spring-framework-bom-4.0.4.RELEASE-javadoc.jar
spring-framework-bom-4.0.4.RELEASE-sources.jar
spring-instrument-4.0.4.RELEASE.jar
spring-instrument-4.0.4.RELEASE-javadoc.jar
spring-instrument-4.0.4.RELEASE-sources.jar
spring-instrument-tomcat-4.0.4.RELEASE.jar
spring-instrument-tomcat-4.0.4.RELEASE-javadoc.jar
spring-instrument-tomcat-4.0.4.RELEASE-sources.jar
spring-jdbc-4.0.4.RELEASE.jar
spring-jdbc-4.0.4.RELEASE-javadoc.jar
spring-jdbc-4.0.4.RELEASE-sources.jar
spring-jms-4.0.4.RELEASE.jar
spring-jms-4.0.4.RELEASE-javadoc.jar
spring-jms-4.0.4.RELEASE-sources.jar
spring-messaging-4.0.4.RELEASE.jar
spring-messaging-4.0.4.RELEASE-javadoc.jar
spring-messaging-4.0.4.RELEASE-sources.jar
spring-orm-4.0.4.RELEASE.jar
spring-orm-4.0.4.RELEASE-javadoc.jar
spring-orm-4.0.4.RELEASE-sources.jar
spring-oxm-4.0.4.RELEASE.jar
spring-oxm-4.0.4.RELEASE-javadoc.jar
spring-oxm-4.0.4.RELEASE-sources.jar
spring-test-4.0.4.RELEASE.jar
spring-test-4.0.4.RELEASE-javadoc.jar
spring-test-4.0.4.RELEASE-sources.jar
spring-tx-4.0.4.RELEASE.jar
spring-tx-4.0.4.RELEASE-javadoc.jar
spring-tx-4.0.4.RELEASE-sources.jar
spring-web-4.0.4.RELEASE.jar
spring-web-4.0.4.RELEASE-javadoc.jar
spring-web-4.0.4.RELEASE-sources.jar
spring-webmvc-4.0.4.RELEASE.jar
spring-webmvc-4.0.4.RELEASE-javadoc.jar
spring-webmvc-4.0.4.RELEASE-sources.jar
spring-webmvc-portlet-4.0.4.RELEASE.jar
spring-webmvc-portlet-4.0.4.RELEASE-javadoc.jar
spring-webmvc-portlet-4.0.4.RELEASE-sources.jar
spring-websocket-4.0.4.RELEASE.jar
spring-websocket-4.0.4.RELEASE-javadoc.jar
spring-websocket-4.0.4.RELEASE-sources.jar
</code>```

答:
```<code><bean id="id2" class="logincontroller"/>
</code>```

this line is causing this issue.

You need to mention fully qualified class name in class attribute. something like this.

```<code> <bean id="id2" class="X.logincontroller"/>
</code>```

where X is your fully qualified package name.

Body:
Hello all i am new to Spring please solve my problem i am getting bean creation exception here is my code(i created these in dynamic web project) i am trying to do a simple Springmvc project.

file name:  login.Jsp

<form action="login.do" method="post">
username<input type="text" name="username"/>
password<input type="password" name="password"/>
<input type="submit" value="login"/>
</form>

file name : web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">

  <servlet>
  <servlet-name>loginapp</servlet-name>
  <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
  </servlet>
  <servlet-mapping>
  <servlet-name>loginapp</servlet-name>
  <url-pattern>*.do</url-pattern>
  </servlet-mapping>

</web-app>

file name:loginapp-servlet.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd">
<beans>
        <bean id="id1" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
          <property name="mappings">
             <props>
                 <prop key="login.do">id2</prop>

        </props>
        </property>
        </bean>
        <bean id="id2" class="logincontroller"/>
</beans>

file name : logincontroller.java

package springmvc;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

public class logincontroller implements Controller {

    @Override
    public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {

        String username = request.getParameter("username");
        String password = request.getParameter("password");
        loginaction action = new loginaction();
        String result = action.verifyuser(username,password);
        if(result.equals("success"))
        return new ModelAndView("success.jsp");
        else
            return new ModelAndView("failure.jsp");

    }

}

filename : success.jsp

<% out.println("login success");%>

file name: failure.jsp

<% out.println("failed");%>

after i run login.jsp and typing username as "admin" password as "admin" i am getting this error

HTTP Status 500 - Servlet.init() for servlet loginapp threw exception

type Exception report

message Servlet.init() for servlet loginapp threw exception

description The server encountered an internal error that prevented it from fulfilling this request.

exception
javax.servlet.ServletException: Servlet.init() for servlet loginapp threw exception
    org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
    org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)
    org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:784)
    org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
    org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:802)
    org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1410)
    org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    java.lang.Thread.run(Unknown Source)

root cause
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'id1' defined in ServletContext resource [/WEB-INF/loginapp-servlet.xml]: Initialization of bean failed; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [logincontroller] for bean with name 'id2' defined in ServletContext resource [/WEB-INF/loginapp-servlet.xml]; nested exception is java.lang.ClassNotFoundException: logincontroller
Related cause: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [logincontroller] for bean with name 'id2' defined in ServletContext resource [/WEB-INF/loginapp-servlet.xml]; nested exception is java.lang.ClassNotFoundException: logincontroller
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:547)
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
    org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)
    org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
    org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
    org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
    org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:703)
    org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760)
    org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
    org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:658)
    org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:624)
    org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:672)
    org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:543)
    org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:484)
    org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)
    javax.servlet.GenericServlet.init(GenericServlet.java:158)
    org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
    org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)
    org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:784)
    org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
    org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:802)
    org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1410)
    org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    java.lang.Thread.run(Unknown Source)

root cause
org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [logincontroller] for bean with name 'id2' defined in ServletContext resource [/WEB-INF/loginapp-servlet.xml]; nested exception is java.lang.ClassNotFoundException: logincontroller
    org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1327)
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:594)
    org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1396)
    org.springframework.beans.factory.support.AbstractBeanFactory.isSingleton(AbstractBeanFactory.java:422)
    org.springframework.context.support.AbstractApplicationContext.isSingleton(AbstractApplicationContext.java:1002)
    org.springframework.web.servlet.handler.AbstractUrlHandlerMapping.registerHandler(AbstractUrlHandlerMapping.java:286)
    org.springframework.web.servlet.handler.SimpleUrlHandlerMapping.registerHandlers(SimpleUrlHandlerMapping.java:129)
    org.springframework.web.servlet.handler.SimpleUrlHandlerMapping.initApplicationContext(SimpleUrlHandlerMapping.java:104)
    org.springframework.context.support.ApplicationObjectSupport.initApplicationContext(ApplicationObjectSupport.java:120)
    org.springframework.web.context.support.WebApplicationObjectSupport.initApplicationContext(WebApplicationObjectSupport.java:73)
    org.springframework.context.support.ApplicationObjectSupport.setApplicationContext(ApplicationObjectSupport.java:74)
    org.springframework.context.support.ApplicationContextAwareProcessor.invokeAwareInterfaces(ApplicationContextAwareProcessor.java:119)
    org.springframework.context.support.ApplicationContextAwareProcessor.postProcessBeforeInitialization(ApplicationContextAwareProcessor.java:94)
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:407)
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1545)
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
    org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)
    org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
    org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
    org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
    org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:703)
    org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760)
    org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
    org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:658)
    org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:624)
    org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:672)
    org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:543)
    org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:484)
    org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)
    javax.servlet.GenericServlet.init(GenericServlet.java:158)
    org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
    org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)
    org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:784)
    org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
    org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:802)
    org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1410)
    org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    java.lang.Thread.run(Unknown Source)

root cause
java.lang.ClassNotFoundException: logincontroller
    org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1285)
    org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1119)
    org.springframework.util.ClassUtils.forName(ClassUtils.java:247)
    org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:395)
    org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.java:1348)
    org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1319)
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:594)
    org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1396)
    org.springframework.beans.factory.support.AbstractBeanFactory.isSingleton(AbstractBeanFactory.java:422)
    org.springframework.context.support.AbstractApplicationContext.isSingleton(AbstractApplicationContext.java:1002)
    org.springframework.web.servlet.handler.AbstractUrlHandlerMapping.registerHandler(AbstractUrlHandlerMapping.java:286)
    org.springframework.web.servlet.handler.SimpleUrlHandlerMapping.registerHandlers(SimpleUrlHandlerMapping.java:129)
    org.springframework.web.servlet.handler.SimpleUrlHandlerMapping.initApplicationContext(SimpleUrlHandlerMapping.java:104)
    org.springframework.context.support.ApplicationObjectSupport.initApplicationContext(ApplicationObjectSupport.java:120)
    org.springframework.web.context.support.WebApplicationObjectSupport.initApplicationContext(WebApplicationObjectSupport.java:73)
    org.springframework.context.support.ApplicationObjectSupport.setApplicationContext(ApplicationObjectSupport.java:74)
    org.springframework.context.support.ApplicationContextAwareProcessor.invokeAwareInterfaces(ApplicationContextAwareProcessor.java:119)
    org.springframework.context.support.ApplicationContextAwareProcessor.postProcessBeforeInitialization(ApplicationContextAwareProcessor.java:94)
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:407)
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1545)
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
    org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
    org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)
    org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
    org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
    org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
    org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:703)
    org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760)
    org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
    org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:658)
    org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:624)
    org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:672)
    org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:543)
    org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:484)
    org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)
    javax.servlet.GenericServlet.init(GenericServlet.java:158)
    org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
    org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)
    org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:784)
    org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
    org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:802)
    org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1410)
    org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    java.lang.Thread.run(Unknown Source)

note The full stack trace of the root cause is available in the Pivotal tc Runtime 3.2.2.RELEASE/8.5.6.B.RELEASE logs.

--------------------------------------------------------------------------------

Pivotal tc Runtime 3.2.2.RELEASE/8.5.6.B.RELEASE

Here are the jar files i copied in lib folder :

commons-logging-1.2.jar
spring-aop-4.0.4.RELEASE.jar
spring-aop-4.0.4.RELEASE-javadoc.jar
spring-aop-4.0.4.RELEASE-sources.jar
spring-aspects-4.0.4.RELEASE.jar
spring-aspects-4.0.4.RELEASE-javadoc.jar
spring-aspects-4.0.4.RELEASE-sources.jar
spring-beans-4.0.4.RELEASE.jar
spring-beans-4.0.4.RELEASE-javadoc.jar
spring-beans-4.0.4.RELEASE-sources.jar
spring-build-src-4.0.4.RELEASE.jar
spring-context-4.0.4.RELEASE.jar
spring-context-4.0.4.RELEASE-javadoc.jar
spring-context-4.0.4.RELEASE-sources.jar
spring-context-support-4.0.4.RELEASE.jar
spring-context-support-4.0.4.RELEASE-javadoc.jar
spring-context-support-4.0.4.RELEASE-sources.jar
spring-core-4.0.4.RELEASE.jar
spring-core-4.0.4.RELEASE-javadoc.jar
spring-core-4.0.4.RELEASE-sources.jar
spring-expression-4.0.4.RELEASE.jar
spring-expression-4.0.4.RELEASE-javadoc.jar
spring-expression-4.0.4.RELEASE-sources.jar
spring-framework-bom-4.0.4.RELEASE.jar
spring-framework-bom-4.0.4.RELEASE-javadoc.jar
spring-framework-bom-4.0.4.RELEASE-sources.jar
spring-instrument-4.0.4.RELEASE.jar
spring-instrument-4.0.4.RELEASE-javadoc.jar
spring-instrument-4.0.4.RELEASE-sources.jar
spring-instrument-tomcat-4.0.4.RELEASE.jar
spring-instrument-tomcat-4.0.4.RELEASE-javadoc.jar
spring-instrument-tomcat-4.0.4.RELEASE-sources.jar
spring-jdbc-4.0.4.RELEASE.jar
spring-jdbc-4.0.4.RELEASE-javadoc.jar
spring-jdbc-4.0.4.RELEASE-sources.jar
spring-jms-4.0.4.RELEASE.jar
spring-jms-4.0.4.RELEASE-javadoc.jar
spring-jms-4.0.4.RELEASE-sources.jar
spring-messaging-4.0.4.RELEASE.jar
spring-messaging-4.0.4.RELEASE-javadoc.jar
spring-messaging-4.0.4.RELEASE-sources.jar
spring-orm-4.0.4.RELEASE.jar
spring-orm-4.0.4.RELEASE-javadoc.jar
spring-orm-4.0.4.RELEASE-sources.jar
spring-oxm-4.0.4.RELEASE.jar
spring-oxm-4.0.4.RELEASE-javadoc.jar
spring-oxm-4.0.4.RELEASE-sources.jar
spring-test-4.0.4.RELEASE.jar
spring-test-4.0.4.RELEASE-javadoc.jar
spring-test-4.0.4.RELEASE-sources.jar
spring-tx-4.0.4.RELEASE.jar
spring-tx-4.0.4.RELEASE-javadoc.jar
spring-tx-4.0.4.RELEASE-sources.jar
spring-web-4.0.4.RELEASE.jar
spring-web-4.0.4.RELEASE-javadoc.jar
spring-web-4.0.4.RELEASE-sources.jar
spring-webmvc-4.0.4.RELEASE.jar
spring-webmvc-4.0.4.RELEASE-javadoc.jar
spring-webmvc-4.0.4.RELEASE-sources.jar
spring-webmvc-portlet-4.0.4.RELEASE.jar
spring-webmvc-portlet-4.0.4.RELEASE-javadoc.jar
spring-webmvc-portlet-4.0.4.RELEASE-sources.jar
spring-websocket-4.0.4.RELEASE.jar
spring-websocket-4.0.4.RELEASE-javadoc.jar
spring-websocket-4.0.4.RELEASE-sources.jar

Body:
<bean id="id2" class="logincontroller"/>

this line is causing this issue.

You need to mention fully qualified class name in class attribute. something like this.

 <bean id="id2" class="X.logincontroller"/>

where X is your fully qualified package name.


来源: stackexchange

问:
DirectX with VB.NET
Is there a set of documentation on DirectX (9 or above) that shows the objects, methods, properties, events and samlple code for the use of DirectX (9 or above) with VB.NET?
The most recent SDK includes details for C++ and the "Windows DiectX Graphics documentation" file doesn't contain these details.</p>

答:
Here is an example that uses vb.net and C++ dll in visual studio 2017
Features:

A Universal Windows Project (UWP) in VB that uses a XAML control
SwapChainPanel.

Calls a standard win32 dll The dll initializes the
DirectX, creates a thread and renders the SwapChainPanel from the dll
code written in C++.

Compiled in Visual Studio 2017

In Visual Basic add a SwapChainPanel to MainPage.xaml

```<code><SwapChainPanel x:Name="swapChainPanel1">
        <TextBlock x:Name="txt1" Text="Hello from XAML!"
               HorizontalAlignment="Right"
               VerticalAlignment="Top"
               FontSize="30" />
        <Button Content="Button" HorizontalAlignment="Left" Height="30" Margin="812,484,0,0" VerticalAlignment="Top" Width="97" Click="Button_Click"/>
        <Button Content="Button" HorizontalAlignment="Left" Height="79" Margin="851,561,0,0" VerticalAlignment="Top" Width="126" Click="Button_Click_1"/>

</SwapChainPanel>
</code>```

In MainPage.xaml.vb

```<code>Imports System.Runtime.InteropServices      ' Required for dll calling. Our C dll is "dhv.dll"

    <DllImport("dhv.dll", CallingConvention:=CallingConvention.StdCall)>
    Private Shared Function D3DInit(ByVal swapChainNative As IntPtr) As UInteger
    End Function

    <DllImport("dhv.dll", CallingConvention:=CallingConvention.StdCall)>
    Private Shared Function D3DRender() As UInteger
    End Function

 Dim SwapChainNative As IntPtr

    Private Sub Tst(ByRef s As SwapChainPanel)              ' this is the Vb implementation of QueryInterface on SwapChainPanel cast as IUnknown. See the DirectX documentation
        Dim inspectableIface As IntPtr
        Dim uuid As New Guid("F92F19D2-3ADE-45A6-A20C-F6F1EA90554B")    ' GUID of ISwapChainPanelNative decalred in <windows.ui.xaml.media.dxinterop.h>

        inspectableIface = System.Runtime.InteropServices.Marshal.GetIUnknownForObject(s)
        System.Runtime.InteropServices.Marshal.QueryInterface(inspectableIface, uuid, SwapChainNative)
    End Sub

    Private Sub Button_Click(sender As Object, e As RoutedEventArgs)
        Dim r As UInt32
        Tst(Me.swapChainPanel1)
        r = D3DInit(SwapChainNative)
        Me.txt1.Text = r
    End Sub

    Private Sub Button_Click_1(sender As Object, e As RoutedEventArgs)
        D3DRender()
    End Sub
</code>```

Create a stabdard Win32 Dll project. It will export two functions. I use a .def file to define the exports. This works very well with vb. No need for other directives such as extern "C" __declspec (dllexport) BOOL __stdcall D3DInit(). Ensure it is called by the linker i.e  /DEF:".\dhv.def"

```<code>LIBRARY   dhv
EXPORTS
    D3DInit=D3DInit
    D3DRender=D3DRender
</code>```

A header file Game.h (This code is based on http://www.directxtutorial.com. The Microsoft code is bloated!

```<code>#pragma once

using namespace Microsoft::WRL;
using namespace DirectX;

class CGame
{

public:
    ComPtr<ID3D11Device1> dev;              // the device interface
    ComPtr<ID3D11DeviceContext1> devcon;    // the device context interface
    ComPtr<IDXGISwapChain1> swapchain;      // the swap chain interface
    ComPtr<ID3D11RenderTargetView> rendertarget;

    ComPtr<ID3D11Texture2D> Backbuffer;

    UINT32 Initialize();
    void Update();
    UINT32 Render();
    void InitGraphics();

private:
    float ScreenColour;
    UINT ScreenColourI;

    UINT Width, Height;
    UINT32 * TextureData;

};
</code>```

And a Game.cpp file

```<code>#include "stdafx.h"
#include <wrl/client.h>
#include <d3d11_1.h>
#include <DirectXMath.h>
#include <windows.ui.xaml.media.dxinterop.h>
#include "Game.h"

DWORD WINAPI renderThread(LPVOID lpParameter);

CGame* pGame;
ComPtr<ISwapChainPanelNative> pSwapChainNative;

UINT32 __stdcall D3DInit(PULONG ptrSwapChainNative)
{
    UINT r;
    pGame = new CGame;
    pSwapChainNative = reinterpret_cast<ISwapChainPanelNative*> (ptrSwapChainNative);
    r = pGame->Initialize();

    return r;
}
UINT32 __stdcall D3DRender(void)
{

    CreateThread(NULL, NULL, renderThread, NULL, 0, NULL);
    return 0;
}

DWORD WINAPI renderThread(LPVOID lpParameter)
{

    for (int i = 0; i < 500; i++)
    {
        //pGame->Update();
        pGame->Render();
    }
    return 1;
}

// this function initializes and prepares Direct3D for use
UINT32 CGame::Initialize()
{
    HRESULT hr;
    // Define temporary pointers to a device and a device context
    ComPtr<ID3D11Device> dev11;
    ComPtr<ID3D11DeviceContext> devcon11;

    // Create the device and device context objects
    D3D11CreateDevice(
        nullptr,
        D3D_DRIVER_TYPE_HARDWARE,
        nullptr,
        0,
        nullptr,
        0,
        D3D11_SDK_VERSION,
        &dev11,
        nullptr,
        &devcon11);

    // Convert the pointers from the DirectX 11 versions to the DirectX 11.1 versions
    dev11.As(&dev);
    devcon11.As(&devcon);

    // First, convert our ID3D11Device1 into an IDXGIDevice1
    ComPtr<IDXGIDevice1> dxgiDevice;
    dev.As(&dxgiDevice);

    // Second, use the IDXGIDevice1 interface to get access to the adapter
    ComPtr<IDXGIAdapter> dxgiAdapter;
    dxgiDevice->GetAdapter(&dxgiAdapter);

    // Third, use the IDXGIAdapter interface to get access to the factory
    ComPtr<IDXGIFactory2> dxgiFactory;
    dxgiAdapter->GetParent(__uuidof(IDXGIFactory2), &dxgiFactory);

    /*
    // set up the swap chain description
    DXGI_SWAP_CHAIN_DESC1 scd = {0};
    scd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;    // how the swap chain should be used
    scd.BufferCount = 2;                                  // a front buffer and a back buffer
    scd.Format = DXGI_FORMAT_B8G8R8A8_UNORM;              // the most common swap chain format
    scd.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL;    // the recommended flip mode
    scd.SampleDesc.Count = 1;                             // disable anti-aliasing

    CoreWindow^ Window = CoreWindow::GetForCurrentThread();    // get the window pointer

    hr = dxgiFactory->CreateSwapChainForCoreWindow(
    dev.Get(),                                  // address of the device
    reinterpret_cast<IUnknown*>(Window),        // address of the window
    &scd,                                       // address of the swap chain description
    nullptr,                                    // advanced
    &swapchain);
    */

    DXGI_SWAP_CHAIN_DESC1 scd = { 0 };
    scd.Width = 1000;           //BUG setting it arbitarily. Needs cleanup. by Ravi
    scd.Height = 800;
    scd.Format = DXGI_FORMAT_B8G8R8A8_UNORM;           // this is the most common swapchain format
    scd.Stereo = false;
    scd.SampleDesc.Count = 1;                          // don't use multi-sampling
    scd.SampleDesc.Quality = 0;
    scd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
    scd.BufferCount = 2;
    scd.Scaling = DXGI_SCALING_STRETCH;
    scd.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL; // we recommend using this swap effect for all applications
    scd.Flags = 0;

    hr = dxgiFactory->CreateSwapChainForComposition(
        dev.Get(),
        &scd,
        nullptr,                                    // allow on any display
        &swapchain);

    if (FAILED(hr))
    {
        return  204;
    }

    pSwapChainNative->SetSwapChain(swapchain.Get());

    // get a pointer directly to the back buffer
    swapchain->GetBuffer(0, __uuidof(ID3D11Texture2D), &Backbuffer);

    // create a render target pointing to the back buffer
    dev->CreateRenderTargetView(Backbuffer.Get(), nullptr, &rendertarget);

    // Width and Height
    swapchain->GetDesc1(&scd);
    Width = scd.Width;
    Height = scd.Height;

    TextureData = new UINT32[Width * Height];

    // initialize graphics and the pipeline
    InitGraphics();

    return 0;
}

// this function performs updates to the state of the game
void CGame::Update()
{
}

// this function renders a single frame of 3D graphics
UINT32 CGame::Render()
{
    UINT n, i;
    UINT  * psrc;
/*
    // set our new render target object as the active render target
    devcon->OMSetRenderTargets(1, rendertarget.GetAddressOf(), nullptr);

    ScreenColour += 0.005f;
    if (ScreenColour >0.9f)
        ScreenColour = 0.0f;

    // clear the back buffer to a deep blue
    float color[4] = {ScreenColour, ScreenColour, ScreenColour, 1.0f};
    devcon->ClearRenderTargetView(rendertarget.Get(), color);
*/
    psrc = TextureData;
    i = ScreenColourI & 255;

    for (n=0; n<Width*Height; n++)
    {
        *psrc++ = (i<<16) | (i<<8) | i ;
        i++;
        i &= 255;
    }

    ScreenColourI += 1;

    devcon->UpdateSubresource (Backbuffer.Get(), 0, NULL, TextureData, Width*4, 0);

    // switch the back buffer and the front buffer
    swapchain->Present(1, 0);

    return 0;

}

// this function loads and initializes all graphics data
void CGame::InitGraphics()
{
    ScreenColour = 0.0f;
    ScreenColourI = 0;
}
</code>```

And finally don't forget to like D3D11.lib

There you go, the VB window gets painted from the DirectX unmanaged dll at 60Hz!

Ravi

ContentLicense: CC BY-SA 2.5

Title: DirectX with VB.NET

Body:
Here is an example that uses vb.net and C++ dll in visual studio 2017
Features:

A Universal Windows Project (UWP) in VB that uses a XAML control
SwapChainPanel.

Calls a standard win32 dll The dll initializes the
DirectX, creates a thread and renders the SwapChainPanel from the dll
code written in C++.

Compiled in Visual Studio 2017

In Visual Basic add a SwapChainPanel to MainPage.xaml

<SwapChainPanel x:Name="swapChainPanel1">
        <TextBlock x:Name="txt1" Text="Hello from XAML!"
               HorizontalAlignment="Right"
               VerticalAlignment="Top"
               FontSize="30" />
        <Button Content="Button" HorizontalAlignment="Left" Height="30" Margin="812,484,0,0" VerticalAlignment="Top" Width="97" Click="Button_Click"/>
        <Button Content="Button" HorizontalAlignment="Left" Height="79" Margin="851,561,0,0" VerticalAlignment="Top" Width="126" Click="Button_Click_1"/>

</SwapChainPanel>

In MainPage.xaml.vb

Imports System.Runtime.InteropServices      ' Required for dll calling. Our C dll is "dhv.dll"

    <DllImport("dhv.dll", CallingConvention:=CallingConvention.StdCall)>
    Private Shared Function D3DInit(ByVal swapChainNative As IntPtr) As UInteger
    End Function

    <DllImport("dhv.dll", CallingConvention:=CallingConvention.StdCall)>
    Private Shared Function D3DRender() As UInteger
    End Function

 Dim SwapChainNative As IntPtr

    Private Sub Tst(ByRef s As SwapChainPanel)              ' this is the Vb implementation of QueryInterface on SwapChainPanel cast as IUnknown. See the DirectX documentation
        Dim inspectableIface As IntPtr
        Dim uuid As New Guid("F92F19D2-3ADE-45A6-A20C-F6F1EA90554B")    ' GUID of ISwapChainPanelNative decalred in <windows.ui.xaml.media.dxinterop.h>

        inspectableIface = System.Runtime.InteropServices.Marshal.GetIUnknownForObject(s)
        System.Runtime.InteropServices.Marshal.QueryInterface(inspectableIface, uuid, SwapChainNative)
    End Sub

    Private Sub Button_Click(sender As Object, e As RoutedEventArgs)
        Dim r As UInt32
        Tst(Me.swapChainPanel1)
        r = D3DInit(SwapChainNative)
        Me.txt1.Text = r
    End Sub

    Private Sub Button_Click_1(sender As Object, e As RoutedEventArgs)
        D3DRender()
    End Sub

Create a stabdard Win32 Dll project. It will export two functions. I use a .def file to define the exports. This works very well with vb. No need for other directives such as extern "C" __declspec (dllexport) BOOL __stdcall D3DInit(). Ensure it is called by the linker i.e  /DEF:".\dhv.def"

LIBRARY   dhv
EXPORTS
    D3DInit=D3DInit
    D3DRender=D3DRender

A header file Game.h (This code is based on http://www.directxtutorial.com. The Microsoft code is bloated!

#pragma once

using namespace Microsoft::WRL;
using namespace DirectX;

class CGame
{

public:
    ComPtr<ID3D11Device1> dev;              // the device interface
    ComPtr<ID3D11DeviceContext1> devcon;    // the device context interface
    ComPtr<IDXGISwapChain1> swapchain;      // the swap chain interface
    ComPtr<ID3D11RenderTargetView> rendertarget;

    ComPtr<ID3D11Texture2D> Backbuffer;

    UINT32 Initialize();
    void Update();
    UINT32 Render();
    void InitGraphics();

private:
    float ScreenColour;
    UINT ScreenColourI;

    UINT Width, Height;
    UINT32 * TextureData;

};

And a Game.cpp file

#include "stdafx.h"
#include <wrl/client.h>
#include <d3d11_1.h>
#include <DirectXMath.h>
#include <windows.ui.xaml.media.dxinterop.h>
#include "Game.h"

DWORD WINAPI renderThread(LPVOID lpParameter);

CGame* pGame;
ComPtr<ISwapChainPanelNative> pSwapChainNative;

UINT32 __stdcall D3DInit(PULONG ptrSwapChainNative)
{
    UINT r;
    pGame = new CGame;
    pSwapChainNative = reinterpret_cast<ISwapChainPanelNative*> (ptrSwapChainNative);
    r = pGame->Initialize();

    return r;
}
UINT32 __stdcall D3DRender(void)
{

    CreateThread(NULL, NULL, renderThread, NULL, 0, NULL);
    return 0;
}

DWORD WINAPI renderThread(LPVOID lpParameter)
{

    for (int i = 0; i < 500; i++)
    {
        //pGame->Update();
        pGame->Render();
    }
    return 1;
}

// this function initializes and prepares Direct3D for use
UINT32 CGame::Initialize()
{
    HRESULT hr;
    // Define temporary pointers to a device and a device context
    ComPtr<ID3D11Device> dev11;
    ComPtr<ID3D11DeviceContext> devcon11;

    // Create the device and device context objects
    D3D11CreateDevice(
        nullptr,
        D3D_DRIVER_TYPE_HARDWARE,
        nullptr,
        0,
        nullptr,
        0,
        D3D11_SDK_VERSION,
        &dev11,
        nullptr,
        &devcon11);

    // Convert the pointers from the DirectX 11 versions to the DirectX 11.1 versions
    dev11.As(&dev);
    devcon11.As(&devcon);

    // First, convert our ID3D11Device1 into an IDXGIDevice1
    ComPtr<IDXGIDevice1> dxgiDevice;
    dev.As(&dxgiDevice);

    // Second, use the IDXGIDevice1 interface to get access to the adapter
    ComPtr<IDXGIAdapter> dxgiAdapter;
    dxgiDevice->GetAdapter(&dxgiAdapter);

    // Third, use the IDXGIAdapter interface to get access to the factory
    ComPtr<IDXGIFactory2> dxgiFactory;
    dxgiAdapter->GetParent(__uuidof(IDXGIFactory2), &dxgiFactory);

    /*
    // set up the swap chain description
    DXGI_SWAP_CHAIN_DESC1 scd = {0};
    scd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;    // how the swap chain should be used
    scd.BufferCount = 2;                                  // a front buffer and a back buffer
    scd.Format = DXGI_FORMAT_B8G8R8A8_UNORM;              // the most common swap chain format
    scd.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL;    // the recommended flip mode
    scd.SampleDesc.Count = 1;                             // disable anti-aliasing

    CoreWindow^ Window = CoreWindow::GetForCurrentThread();    // get the window pointer

    hr = dxgiFactory->CreateSwapChainForCoreWindow(
    dev.Get(),                                  // address of the device
    reinterpret_cast<IUnknown*>(Window),        // address of the window
    &scd,                                       // address of the swap chain description
    nullptr,                                    // advanced
    &swapchain);
    */

    DXGI_SWAP_CHAIN_DESC1 scd = { 0 };
    scd.Width = 1000;           //BUG setting it arbitarily. Needs cleanup. by Ravi
    scd.Height = 800;
    scd.Format = DXGI_FORMAT_B8G8R8A8_UNORM;           // this is the most common swapchain format
    scd.Stereo = false;
    scd.SampleDesc.Count = 1;                          // don't use multi-sampling
    scd.SampleDesc.Quality = 0;
    scd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
    scd.BufferCount = 2;
    scd.Scaling = DXGI_SCALING_STRETCH;
    scd.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL; // we recommend using this swap effect for all applications
    scd.Flags = 0;

    hr = dxgiFactory->CreateSwapChainForComposition(
        dev.Get(),
        &scd,
        nullptr,                                    // allow on any display
        &swapchain);

    if (FAILED(hr))
    {
        return  204;
    }

    pSwapChainNative->SetSwapChain(swapchain.Get());

    // get a pointer directly to the back buffer
    swapchain->GetBuffer(0, __uuidof(ID3D11Texture2D), &Backbuffer);

    // create a render target pointing to the back buffer
    dev->CreateRenderTargetView(Backbuffer.Get(), nullptr, &rendertarget);

    // Width and Height
    swapchain->GetDesc1(&scd);
    Width = scd.Width;
    Height = scd.Height;

    TextureData = new UINT32[Width * Height];

    // initialize graphics and the pipeline
    InitGraphics();

    return 0;
}

// this function performs updates to the state of the game
void CGame::Update()
{
}

// this function renders a single frame of 3D graphics
UINT32 CGame::Render()
{
    UINT n, i;
    UINT  * psrc;
/*
    // set our new render target object as the active render target
    devcon->OMSetRenderTargets(1, rendertarget.GetAddressOf(), nullptr);

    ScreenColour += 0.005f;
    if (ScreenColour >0.9f)
        ScreenColour = 0.0f;

    // clear the back buffer to a deep blue
    float color[4] = {ScreenColour, ScreenColour, ScreenColour, 1.0f};
    devcon->ClearRenderTargetView(rendertarget.Get(), color);
*/
    psrc = TextureData;
    i = ScreenColourI & 255;

    for (n=0; n<Width*Height; n++)
    {
        *psrc++ = (i<<16) | (i<<8) | i ;
        i++;
        i &= 255;
    }

    ScreenColourI += 1;

    devcon->UpdateSubresource (Backbuffer.Get(), 0, NULL, TextureData, Width*4, 0);

    // switch the back buffer and the front buffer
    swapchain->Present(1, 0);

    return 0;

}

// this function loads and initializes all graphics data
void CGame::InitGraphics()
{
    ScreenColour = 0.0f;
    ScreenColourI = 0;
}

And finally don't forget to like D3D11.lib

There you go, the VB window gets painted from the DirectX unmanaged dll at 60Hz!

Ravi

ContentLicense: CC BY-SA 3.0


问:
Logging inside Stream
I am trying to convert this piece of code to Java 8 stream:

```<code>if (list != null && !list.isEmpty()) {
    Actor actor = null;
    for (Actor actor : list) {
        log.info("Actor being read: "  actor.getCode());
        List<String> areaList = areaDAO.getArea(actor.getCode());
        if (!areaList.isEmpty()) {
            actor.setArea(areaList.get(0));
            log.info("Area{" + areaList.get(0)
                 + "} is fetched for actor{" + actor.getCode() + "}.");
        }
        this.getContext().setReadCount(1);
    }
}
</code>```

However I am not sure how to deal with logging in this case? Is it a good practice? Appreciate your help. Thanks

答:
I think that using forEach in this case would be working quite nice for you? Example:

```<code>list.stream().forEach(actor -> {
    log.info(String.format("Actor being read {%s}", actor));
    String actorCode = actor.getCode();
    areaDAO.getArea(actorCode).stream().findFirst().ifPresent(area -> {
       actor.setArea(area);
       log.info(String.format("Area {%s} is fetched for actor {%s}", area, actorCode));
    });
    getContext().setReadCount(1);
})
</code>```

You may want to throw in Objects.isNull() as well in some cases - e.g for that getCode part - as well as Optional.ofNullable?

ContentLicense: CC BY-SA 4.0

Title: Logging inside Stream

Body:
I am trying to convert this piece of code to Java 8 stream:

if (list != null && !list.isEmpty()) {
    Actor actor = null;
    for (Actor actor : list) {
        log.info("Actor being read: "  actor.getCode());
        List<String> areaList = areaDAO.getArea(actor.getCode());
        if (!areaList.isEmpty()) {
            actor.setArea(areaList.get(0));
            log.info("Area{" + areaList.get(0)
                 + "} is fetched for actor{" + actor.getCode() + "}.");
        }
        this.getContext().setReadCount(1);
    }
}

However I am not sure how to deal with logging in this case? Is it a good practice? Appreciate your help. Thanks

Body:
I think that using forEach in this case would be working quite nice for you? Example:

list.stream().forEach(actor -> {
    log.info(String.format("Actor being read {%s}", actor));
    String actorCode = actor.getCode();
    areaDAO.getArea(actorCode).stream().findFirst().ifPresent(area -> {
       actor.setArea(area);
       log.info(String.format("Area {%s} is fetched for actor {%s}", area, actorCode));
    });
    getContext().setReadCount(1);
})

You may want to throw in Objects.isNull() as well in some cases - e.g for that getCode part - as well as Optional.ofNullable?


问:
Order by date desc, but within day order by time asc
I have a table in which there is a Date (smalldatetime) column. I need to order by Date DESC, but within each day to order by Date ASC.  The output should be like:

```<code>Date
2017-01-31T09:00:00Z
2017-01-31T17:00:00Z
2017-01-28T09:00:00Z
2017-01-28T17:00:00Z
2017-01-25T09:00:00Z
2017-01-25T17:00:00Z
...
</code>```

Is such a query possible?

If it's of any help, the data contains a maximum of two rows for the same Date.

答:
ORDER BY DATE(date) DESC, TIME(date) ASC;
I hope my answer can help you!

Body:
I have a table in which there is a Date (smalldatetime) column. I need to order by Date DESC, but within each day to order by Date ASC.  The output should be like:

Date
2017-01-31T09:00:00Z
2017-01-31T17:00:00Z
2017-01-28T09:00:00Z
2017-01-28T17:00:00Z
2017-01-25T09:00:00Z
2017-01-25T17:00:00Z
...

Is such a query possible?

If it's of any help, the data contains a maximum of two rows for the same Date.


问:
GraphQL InputObjectType
What will be the input object type for this object variable?

```<code>let data = {
      companyId: "ABCD",
      source: "tally",
      formDataId: "154",
      formData: [{
                    value: "02",
                    fieldPath: "voucher/sales"
                  },
                  {
                    value: "5o kgs",
                    fieldPath: "voucher/sales"
                  },
                  {
                    value: "soap"
                    fieldPath: "voucher/sales"
                  }],
      date: "2017-03-29"
 };
</code>```

I'm confused with the value field because it has multiple types of data.

答:
The GraphQL input type for your data object could look like this:

...

`
input SalePropertyInput {
  value: String!
  relatedProperty: String!
}

input SaleInput {
  companyId: ID!
  source: String!
  properties: [SalePropertyInput!]!
}
`

...```

But i think before you start the mutation you should map the values from the form to the data you really need on the server. E.g. you don't need the formDataId. And i suggest you check the form you're using on the client that the field path can be mapped to some sort of sale property. Which can be used to differentiate the input on the server

Title: GraphQL InputObjectType

Body:
What will be the input object type for this object variable?

let data = {
      companyId: "ABCD",
      source: "tally",
      formDataId: "154",
      formData: [{
                    value: "02",
                    fieldPath: "voucher/sales"
                  },
                  {
                    value: "5o kgs",
                    fieldPath: "voucher/sales"
                  },
                  {
                    value: "soap"
                    fieldPath: "voucher/sales"
                  }],
      date: "2017-03-29"
 };

I'm confused with the value field because it has multiple types of data.

Body:
The GraphQL input type for your data object could look like this:

...

`
input SalePropertyInput {
  value: String!
  relatedProperty: String!
}

input SaleInput {
  companyId: ID!
  source: String!
  properties: [SalePropertyInput!]!
}
`

...

But i think before you start the mutation you should map the values from the form to the data you really need on the server. E.g. you don't need the formDataId. And i suggest you check the form you're using on the client that the field path can be mapped to some sort of sale property. Which can be used to differentiate the input on the server


问:
Segmentation Fault in the Following Program for string comparisons
I am getting segmentation fault for the following code. The logic of the  program that it should accept the correct password ("abcd") and it should deny  access if entered any other password, but I am still getting a segmentation fault after I enter wrong password (eg: "acdc" or "ancgff").I get proper response for passwords like "abc" or "xyz" where I get "access denied" message.

Please help me , unable to understand why I am getting this error?

```<code>#include <stdio.h>
#include <string.h>

int check(char *password)
{
    char pin_buffer[4];

    int authority = 0;

    strcpy(pin_buffer,password);

    if(strcmp(pin_buffer,"abcd")==0)

        authority=1;
    return authority;

}

int main(int argc, char *argv[])
{
    if(argc < 1)
    {
        printf(argv[0]);
        exit(0);
    }

    if(check(argv[1]))
    {
       printf("access granted");
    }
    else
    {
        printf("access denied};
}
</code>```

答:
You define

```<code>char pin_buf[4];
</code>```

with a pre-decided size of 4 and then, without any check, you use

```<code> strcpy(pin_buf,pin);
</code>```

the moment pin has more than 3 elements (and a terminating null), you'll be overrunning the boundary of allocated memory while attempoting to copy which causes undefined behavior.

That is why, you observe

"...I am still getting a segmentation fault after I enter wrong password (eg: "acdc" or "ancgff").I get proper response for passwords like "abc" or "xyz""

That said, you don't need the pin_buf at all. The operations you intend to perform can be done with pin itself.

Body:
I am getting segmentation fault for the following code. The logic of the  program that it should accept the correct password ("abcd") and it should deny  access if entered any other password, but I am still getting a segmentation fault after I enter wrong password (eg: "acdc" or "ancgff").I get proper response for passwords like "abc" or "xyz" where I get "access denied" message.

Please help me , unable to understand why I am getting this error?

#include <stdio.h>
#include <string.h>

int check(char *password)
{
    char pin_buffer[4];

    int authority = 0;

    strcpy(pin_buffer,password);

    if(strcmp(pin_buffer,"abcd")==0)

        authority=1;
    return authority;

}

int main(int argc, char *argv[])
{
    if(argc < 1)
    {
        printf(argv[0]);
        exit(0);
    }

    if(check(argv[1]))
    {
       printf("access granted");
    }
    else
    {
        printf("access denied};
}

Body:
You define

char pin_buf[4];

with a pre-decided size of 4 and then, without any check, you use

 strcpy(pin_buf,pin);

the moment pin has more than 3 elements (and a terminating null), you'll be overrunning the boundary of allocated memory while attempoting to copy which causes undefined behavior.

That is why, you observe

"...I am still getting a segmentation fault after I enter wrong password (eg: "acdc" or "ancgff").I get proper response for passwords like "abc" or "xyz""

That said, you don't need the pin_buf at all. The operations you intend to perform can be done with pin itself.


问:
Related to Graph daa structure
Could anyone please differentiate between implicit graph and explicit graph.Actually i tried to read Wikipedia page related to this topic but got confused.</p>

答:
An explicit graph is an explicitly defined graph, where we know how many nodes and edges are present and which nodes have an edge between them.

An implicit graph is not explicitly defined, meaning we don't know about it's nodes and edges instead we are building the graph as we go in some process.
Which is very commonly in a backtrack search.

For example:  A simple backtrack for generating all subsets of a set {A, B, C}

```<code>#include <iostream>
using namespace std;

char elements[4]= "ABC";

void powerSet(int n, string subset){
    if(n < 0){
        cout<< subset <<endl;
        return;
    }

    powerSet(n-1, subset);
    powerSet(n-1, subset+ elements[n]);
}

int main(){
    powerSet(2, string(""));
}
</code>```

We don't have any graph defined yet we're constructing and using the following tree:  (the recursion tree isn't the exact for the code above but it is very similar )

```<code>       /       \
      /         \
     a           {}
    /  \         / \
   b    {}      b   {}
  / \   / \    / \   /\
 c  {}  c  {}  c {}  c {}
abc ab ac  a  bc  b  c {empty}     :We get these subsets
</code>```

Title: Related to Graph daa structure

Body:
An explicit graph is an explicitly defined graph, where we know how many nodes and edges are present and which nodes have an edge between them.

An implicit graph is not explicitly defined, meaning we don't know about it's nodes and edges instead we are building the graph as we go in some process.
Which is very commonly in a backtrack search.

For example:  A simple backtrack for generating all subsets of a set {A, B, C}

#include <iostream>
using namespace std;

char elements[4]= "ABC";

void powerSet(int n, string subset){
    if(n < 0){
        cout<< subset <<endl;
        return;
    }

    powerSet(n-1, subset);
    powerSet(n-1, subset+ elements[n]);
}

int main(){
    powerSet(2, string(""));
}

We don't have any graph defined yet we're constructing and using the following tree:  (the recursion tree isn't the exact for the code above but it is very similar )

       /       \
      /         \
     a           {}
    /  \         / \
   b    {}      b   {}
  / \   / \    / \   /\
 c  {}  c  {}  c {}  c {}
abc ab ac  a  bc  b  c {empty}     :We get these subsets


问:
Python: Divide each row of a DataFrame by another DataFrame vector
I have a DataFrame (df1) with a dimension 2000 rows x 500 columns (excluding the index) for which I want to divide each row by another DataFrame (df2) with dimension 1 rows X 500 columns. Both have the same column headers. I tried:

df.divide(df2) and
df.divide(df2, axis='index') and multiple other solutions and I always get a df with nan values in every cell. What argument am I missing in the function df.divide?

答:
to divide a row (with single or multiple columns), we need to do the below:</p>

```<code>df.loc['index_value'] = df.loc['index_value'].div(10000)
</code>```

Body:
to divide a row (with single or multiple columns), we need to do the below:

df.loc['index_value'] = df.loc['index_value'].div(10000)


问:
Mask an EditText with Phone Number Format NaN like in PhoneNumberUtils
I want to make user inputted phone number in an editText to dynamically change format every time the user inputs a number. That is, when user inputs up to 4 digits, like 7144, the editText shows "714-4".
I would like the editText to be dynamically updated to format ###-###-#### whenever the user inputs a digit. how can this be done? also, I am handling more than one editTexts.</p>

答:
My script, example taken from here description here

```<code><android.support.design.widget.TextInputLayout
    android:id="@+id/numphone_layout"
    app:hintTextAppearance="@style/MyHintText"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"

    android:layout_marginTop="8dp">

    <android.support.design.widget.TextInputEditText
        android:id="@+id/edit_text_numphone"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/MyEditText"
        android:digits="+() 1234567890-"
        android:hint="@string/hint_numphone"
        android:inputType="phone"
        android:maxLength="17"
        android:textSize="14sp" />
</android.support.design.widget.TextInputLayout>
</code>```

```<code> @Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
 TextInputEditText phone = (TextInputEditText) findViewById(R.id.edit_text_numphone);
 //Add to mask
    phone.addTextChangedListener(textWatcher);
}

   TextWatcher textWatcher = new TextWatcher() {
    private boolean mFormatting; // this is a flag which prevents the  stack overflow.
    private int mAfter;

    @Override
    public void onTextChanged(CharSequence s, int start, int before, int count) {
        // nothing to do here..
    }

    //called before the text is changed...
    @Override
    public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        //nothing to do here...
        mAfter  =   after; // flag to detect backspace..

    }

    @Override
    public void afterTextChanged(Editable s) {
        // Make sure to ignore calls to afterTextChanged caused by the work done below
        if (!mFormatting) {
            mFormatting = true;
            // using US or RU formatting...
            if(mAfter!=0) // in case back space ain't clicked...
            {
                String num =s.toString();
                String data = PhoneNumberUtils.formatNumber(num, "RU");
                if(data!=null)
                {
                    s.clear();
                    s.append(data);
                    Log.i("Number", data);//8 (999) 123-45-67 or +7 999 123-45-67
                }

            }
            mFormatting = false;
        }
    }
};
</code>```

Body:
My script, example taken from here description here

<android.support.design.widget.TextInputLayout
    android:id="@+id/numphone_layout"
    app:hintTextAppearance="@style/MyHintText"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"

    android:layout_marginTop="8dp">

    <android.support.design.widget.TextInputEditText
        android:id="@+id/edit_text_numphone"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/MyEditText"
        android:digits="+() 1234567890-"
        android:hint="@string/hint_numphone"
        android:inputType="phone"
        android:maxLength="17"
        android:textSize="14sp" />
</android.support.design.widget.TextInputLayout>

 @Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
 TextInputEditText phone = (TextInputEditText) findViewById(R.id.edit_text_numphone);
 //Add to mask
    phone.addTextChangedListener(textWatcher);
}

   TextWatcher textWatcher = new TextWatcher() {
    private boolean mFormatting; // this is a flag which prevents the  stack overflow.
    private int mAfter;

    @Override
    public void onTextChanged(CharSequence s, int start, int before, int count) {
        // nothing to do here..
    }

    //called before the text is changed...
    @Override
    public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        //nothing to do here...
        mAfter  =   after; // flag to detect backspace..

    }

    @Override
    public void afterTextChanged(Editable s) {
        // Make sure to ignore calls to afterTextChanged caused by the work done below
        if (!mFormatting) {
            mFormatting = true;
            // using US or RU formatting...
            if(mAfter!=0) // in case back space ain't clicked...
            {
                String num =s.toString();
                String data = PhoneNumberUtils.formatNumber(num, "RU");
                if(data!=null)
                {
                    s.clear();
                    s.append(data);
                    Log.i("Number", data);//8 (999) 123-45-67 or +7 999 123-45-67
                }

            }
            mFormatting = false;
        }
    }
};


问:
Text Spilling Outside of Div

The screenshot above shows the problem. Unlike the other similar question I don't need this to work for international text. I need this to work for varying screen sizes and varying amounts of text. The text will come from a databse in production, so I can't simply figure out the breakpoint at which the div needs to move down in advance.

The solution I am looking for would first  move the text block below the image, and then resize the text div vertically as necessary to accomidate all the text. JS or CSS solutions are fine.

HTML below:

```<code><div class="product">
    <img class="productImg" src="http://placehold.it/300x240">
    <div class="productTxt">
        <h1>Title</h1>
        <h3>Price</h3>
        <p>Suspendisse sed fermentum neque, vel rutrum velit. Curabitur eget dolor luctus, sodales felis sed, dapibus justo.
        Suspendisse in condimentum ante. Sed nec dui tristique, sollicitudin velit eget, ultricies dui.
        Ut rhoncus ornare urna, quis venenatis velit ornare eu. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.
        Etiam ornare sem finibus lectus volutpat, in feugiat elit ultrices. In sed vulputate eros, quis volutpat elit.
        Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse nisi libero, posuere nec laoreet quis, viverra et lorem. Duis odio ante, efficitur et felis at, tincidunt interdum ante.
        Quisque vestibulum eu est a egestas. Nunc hendrerit rutrum dui at cursus. Aliquam mollis nec magna ac mattis.
        Nam nec est tincidunt leo facilisis finibus non nec mauris. Vestibulum rutrum tristique tincidunt. </p>
    </div>
</div>
</code>```

CSS:

```<code>.product {
    box-sizing: border-box;
    margin: 0px;
    padding: 10px;
    width: 100%;
    height: 330px;
    border-bottom: 2px solid #16A085;
}

.productImg {
    width: 240px;
    height: 300px;
    display: inline-block;
    position: relative;
}

.productTxt {
    box-sizing: border-box;
    vertical-align: top;
    display: inline-block;
    height: 100%;
    width: calc(100% - 270px);
    padding: 10px;
    text-align: center;
    position: relative;
    border: 2px solid blue;
 }
</code>```

I can't really remove the relative positioning from the productTxt div without breaking the positioning of another element that is within the same div (which I have removed for simplicity in this example)

答:
To move the text block below the image remove display: inline-block; from .productTxt class.
If you want to keep the height of .product class fix then adjust height of .productTxt according to .product class and give css overflow: auto; to .productTxt all you data will displayed with scroll panel,so your HTML is

```<code><div class="product">
     <img class="productImg" src="http://placehold.it/300x240">
     <div class="productTxt">
         <h1>Title</h1>
         <h3>Price</h3>
         <p>Suspendisse sed fermentum neque, vel rutrum velit.
            Curabitur eget dolor luctus, sodales felis sed, dapibus
            justo.Suspendisse in condimentum ante. Sed nec dui
            tristique,sollicitudin velit eget, ultricies dui.
            Ut rhoncus ornare urna, quis venenatis velit ornare eu.
            Pellentesque habitant morbi tristique senectus et netus et
            malesuada fames ac turpis egestas.
            Etiam ornare sem finibus lectus volutpat, in feugiat elit
            ultrices. In sed vulputate eros, quis volutpat elit.
            Lorem ipsum dolor sit amet, consectetur adipiscing elit.
            Suspendisse nisi libero, posuere nec laoreet quis, viverra
            et lorem. Duis odio ante, efficitur et felis at, tincidunt
            interdum ante.
            Quisque vestibulum eu est a egestas. Nunc hendrerit rutrum
            dui at cursus. Aliquam mollis nec magna ac mattis.
            Nam nec est tincidunt leo facilisis finibus non nec
            mauris.Vestibulum rutrum tristique tincidunt.
        </p>
       </div>
</div>
</code>```

And your CSS will be

```<code>.product {
    box-sizing: border-box;
    margin: 0px;
    padding: 10px;
    width: 100%;
    height: 550px;
    border-bottom: 2px solid #16A085;
}

.productImg {
    width: 240px;
    height: 300px;
    display: inline-block;
    position: relative;
}

.productTxt {
   box-sizing: border-box;
   vertical-align: top;
   height: 230px;
   width: calc(100% - 270px);
   padding: 10px;
   text-align: center;
   position: relative;
   border: 2px solid blue;
   overflow: auto;
}
</code>```

Title: Text Spilling Outside of Div

Body:
The screenshot above shows the problem. Unlike the other similar question I don't need this to work for international text. I need this to work for varying screen sizes and varying amounts of text. The text will come from a databse in production, so I can't simply figure out the breakpoint at which the div needs to move down in advance.

The solution I am looking for would first  move the text block below the image, and then resize the text div vertically as necessary to accomidate all the text. JS or CSS solutions are fine.

HTML below:

Title

Price

Suspendisse sed fermentum neque, vel rutrum velit. Curabitur eget dolor luctus, sodales felis sed, dapibus justo.
        Suspendisse in condimentum ante. Sed nec dui tristique, sollicitudin velit eget, ultricies dui.
        Ut rhoncus ornare urna, quis venenatis velit ornare eu. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.
        Etiam ornare sem finibus lectus volutpat, in feugiat elit ultrices. In sed vulputate eros, quis volutpat elit.
        Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse nisi libero, posuere nec laoreet quis, viverra et lorem. Duis odio ante, efficitur et felis at, tincidunt interdum ante.
        Quisque vestibulum eu est a egestas. Nunc hendrerit rutrum dui at cursus. Aliquam mollis nec magna ac mattis.
        Nam nec est tincidunt leo facilisis finibus non nec mauris. Vestibulum rutrum tristique tincidunt.

CSS:

.product {
    box-sizing: border-box;
    margin: 0px;
    padding: 10px;
    width: 100%;
    height: 330px;
    border-bottom: 2px solid #16A085;
}

.productImg {
    width: 240px;
    height: 300px;
    display: inline-block;
    position: relative;
}

.productTxt {
    box-sizing: border-box;
    vertical-align: top;
    display: inline-block;
    height: 100%;
    width: calc(100% - 270px);
    padding: 10px;
    text-align: center;
    position: relative;
    border: 2px solid blue;
 }

I can't really remove the relative positioning from the productTxt div without breaking the positioning of another element that is within the same div (which I have removed for simplicity in this example)

Body:
To move the text block below the image remove display: inline-block; from .productTxt class.
If you want to keep the height of .product class fix then adjust height of .productTxt according to .product class and give css overflow: auto; to .productTxt all you data will displayed with scroll panel,so your HTML is

<div class="product">
     <img class="productImg" src="http://placehold.it/300x240">
     <div class="productTxt">
         <h1>Title</h1>
         <h3>Price</h3>
         <p>Suspendisse sed fermentum neque, vel rutrum velit.
            Curabitur eget dolor luctus, sodales felis sed, dapibus
            justo.Suspendisse in condimentum ante. Sed nec dui
            tristique,sollicitudin velit eget, ultricies dui.
            Ut rhoncus ornare urna, quis venenatis velit ornare eu.
            Pellentesque habitant morbi tristique senectus et netus et
            malesuada fames ac turpis egestas.
            Etiam ornare sem finibus lectus volutpat, in feugiat elit
            ultrices. In sed vulputate eros, quis volutpat elit.
            Lorem ipsum dolor sit amet, consectetur adipiscing elit.
            Suspendisse nisi libero, posuere nec laoreet quis, viverra
            et lorem. Duis odio ante, efficitur et felis at, tincidunt
            interdum ante.
            Quisque vestibulum eu est a egestas. Nunc hendrerit rutrum
            dui at cursus. Aliquam mollis nec magna ac mattis.
            Nam nec est tincidunt leo facilisis finibus non nec
            mauris.Vestibulum rutrum tristique tincidunt.
        </p>
       </div>
</div>

And your CSS will be

.product {
    box-sizing: border-box;
    margin: 0px;
    padding: 10px;
    width: 100%;
    height: 550px;
    border-bottom: 2px solid #16A085;
}

.productImg {
    width: 240px;
    height: 300px;
    display: inline-block;
    position: relative;
}

.productTxt {
   box-sizing: border-box;
   vertical-align: top;
   height: 230px;
   width: calc(100% - 270px);
   padding: 10px;
   text-align: center;
   position: relative;
   border: 2px solid blue;
   overflow: auto;
}


问:
How to access data from ajax call after the ajax call ends
I am making a ajax calls that returns me some data from the server. I work on string function on the data that come from ajax call. From my knowledge i can see the string operation begins before the ajax call gets over. Often giving me undefined error. Here is my ajax call

```<code> $.ajax({

        type: "POST",
        url: "/add_director",
        headers: {'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')},
        data: formData,
        cache: false,
        contentType: false,
        processData: false,
        success: function(data) {
            $('#addDirModal').modal('hide');
            insertDirector(data);
        },
        error : function(xhr ,status ,error)
        {
            console.log(xhr);
            alert(xhr);
        }
    });
</code>```

Here is my insertDirector function

```<code>function insertDirector(data){
      console.log(data);
      if (data.msg == "1") {
        $.each(data,function(key,value){
            var dir_name = value.dir_name;
            var dir_pan = value.dir_pan;
            var dir_din = value.dir_din;
            var dir_addr = value.dir_addr;
            var dir_id = value.id;
            var dir_img = value.dir_img;

              if (dir_name.val().length > 15) {
                var dir_r_name = dir_name.substr(0,15);
              }

              else{
                var dir_r_name = dir_name;
              }
         });
        }
       }
</code>```

Here when i work on substr() it throws the error Cannot read property 'val' of undefined. I can see this is because the substr() is executed before the ajax request is completed. how do i fix this ?

EDITED

Here is the response

```<code>{"msg":"1","director":{"dir_name":"Naveen","dir_pan":"AAAAA1111B","dir_din":"123456","dir_addr":"dsadasdasdasdsadasdas","dir_img":"1490852438.jpg","user_id":3,"updated_at":"2017-03-30 05:40:38","created_at":"2017-03-30 05:40:38","id":15}}
</code>```

答:
After seeing the data you posted, it is easy to find issue.
Here, the issue is:

Your function:

```<code>function insertDirector(data){
      console.log(data);
      if (data.msg == "1") {
        $.each(data,function(key,value){
            var dir_name = value.dir_name;
            var dir_pan = value.dir_pan;
            var dir_din = value.dir_din;
            var dir_addr = value.dir_addr;
            var dir_id = value.id;
            var dir_img = value.dir_img;

              if (dir_name.val().length > 15) {
                var dir_r_name = dir_name.substr(0,15);
              }

              else{
                var dir_r_name = dir_name;
              }
         });
        }
       }
</code>```

Here, when you do $.each, every object inside data will be traversed. Now, your first value inside data is msg:1. This is not a object. As a result, on first iteration, key is 'msg' but value is '1'. Now this value can't have dir_name so undefined is returned. As a result dir_name.val() generates error.

Try it like this:

```<code>function insertDirector(data){
      console.log(data);
      if (data.msg == "1") {
        $.each(data,function(key,value){
            if(key==="director"){
            var dir_name = value.dir_name;
            var dir_pan = value.dir_pan;
            var dir_din = value.dir_din;
            var dir_addr = value.dir_addr;
            var dir_id = value.id;
            var dir_img = value.dir_img;

              if (dir_name.val().length > 15) {
                var dir_r_name = dir_name.substr(0,15);
              }

              else{
                var dir_r_name = dir_name;
              }
            }

         });
        }
       }
</code>```

Body:
I am making a ajax calls that returns me some data from the server. I work on string function on the data that come from ajax call. From my knowledge i can see the string operation begins before the ajax call gets over. Often giving me undefined error. Here is my ajax call

 $.ajax({

        type: "POST",
        url: "/add_director",
        headers: {'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')},
        data: formData,
        cache: false,
        contentType: false,
        processData: false,
        success: function(data) {
            $('#addDirModal').modal('hide');
            insertDirector(data);
        },
        error : function(xhr ,status ,error)
        {
            console.log(xhr);
            alert(xhr);
        }
    });

Here is my insertDirector function

function insertDirector(data){
      console.log(data);
      if (data.msg == "1") {
        $.each(data,function(key,value){
            var dir_name = value.dir_name;
            var dir_pan = value.dir_pan;
            var dir_din = value.dir_din;
            var dir_addr = value.dir_addr;
            var dir_id = value.id;
            var dir_img = value.dir_img;

              if (dir_name.val().length > 15) {
                var dir_r_name = dir_name.substr(0,15);
              }

              else{
                var dir_r_name = dir_name;
              }
         });
        }
       }

Here when i work on substr() it throws the error Cannot read property 'val' of undefined. I can see this is because the substr() is executed before the ajax request is completed. how do i fix this ?

EDITED

Here is the response

{"msg":"1","director":{"dir_name":"Naveen","dir_pan":"AAAAA1111B","dir_din":"123456","dir_addr":"dsadasdasdasdsadasdas","dir_img":"1490852438.jpg","user_id":3,"updated_at":"2017-03-30 05:40:38","created_at":"2017-03-30 05:40:38","id":15}}

Body:
After seeing the data you posted, it is easy to find issue.
Here, the issue is:

Your function:

function insertDirector(data){
      console.log(data);
      if (data.msg == "1") {
        $.each(data,function(key,value){
            var dir_name = value.dir_name;
            var dir_pan = value.dir_pan;
            var dir_din = value.dir_din;
            var dir_addr = value.dir_addr;
            var dir_id = value.id;
            var dir_img = value.dir_img;

              if (dir_name.val().length > 15) {
                var dir_r_name = dir_name.substr(0,15);
              }

              else{
                var dir_r_name = dir_name;
              }
         });
        }
       }

Here, when you do $.each, every object inside data will be traversed. Now, your first value inside data is msg:1. This is not a object. As a result, on first iteration, key is 'msg' but value is '1'. Now this value can't have dir_name so undefined is returned. As a result dir_name.val() generates error.

Try it like this:

function insertDirector(data){
      console.log(data);
      if (data.msg == "1") {
        $.each(data,function(key,value){
            if(key==="director"){
            var dir_name = value.dir_name;
            var dir_pan = value.dir_pan;
            var dir_din = value.dir_din;
            var dir_addr = value.dir_addr;
            var dir_id = value.id;
            var dir_img = value.dir_img;

              if (dir_name.val().length > 15) {
                var dir_r_name = dir_name.substr(0,15);
              }

              else{
                var dir_r_name = dir_name;
              }
            }

         });
        }
       }


问:
Neo4J Multiple Match Statement in Single Query
I want to get Total Count of VoteUp and VoteDown on Pixel in Single Query but it return TRUE RESULT when it have Greater then Zero Value that means VoteUp and VoteDown Greater then Zero.

```<code>MATCH (n:pixel)-[vu:vote_up]-(:users),
  (n:pixel)-[vd:vote_down]-(:users)
  WHERE ID(n)=7445 RETURN count(vu),count(vd)
</code>```

Above My Query. it return wrong result when VoteUp Zero and VoteDown Greater then Zero.

答:
I got Solution of My Question from Following Query:

```<code>MATCH (n:pixel)WHERE ID(n)=7445
RETURN
size((n)-[:vote_up]-(:users)) as VoteUp,
size((n)-[:vote_down]-(:users)) as VoteDown
</code>```

Finded Reference From Here

Body:
I want to get Total Count of VoteUp and VoteDown on Pixel in Single Query but it return TRUE RESULT when it have Greater then Zero Value that means VoteUp and VoteDown Greater then Zero.

MATCH (n:pixel)-[vu:vote_up]-(:users),
  (n:pixel)-[vd:vote_down]-(:users)
  WHERE ID(n)=7445 RETURN count(vu),count(vd)

Above My Query. it return wrong result when VoteUp Zero and VoteDown Greater then Zero.

Body:
I got Solution of My Question from Following Query:

MATCH (n:pixel)WHERE ID(n)=7445
RETURN
size((n)-[:vote_up]-(:users)) as VoteUp,
size((n)-[:vote_down]-(:users)) as VoteDown

Finded Reference From Here


问:
Can I just make up attributes on my HTML tags?
Am I allowed to add whatever attributes I want to HTML tags such that I can retrieve their value later on using javascript? For example:

```<code><a href="something.html" hastooltip="yes" tipcolour="yellow">...</a>
</code>```

If that's not going to work, how would you store arbitrary pieces of information like this?

Edit: Since it appears that making up HTML attributes isn't technically valid, I've rephrased the second part of this question into its own question here: How to store arbitrary data for some HTML tags

答:
In HTML5, yes. You just have to prefix them with data-. See the spec.

Of course, this implies you should be using the HTML5 doctype (<!doctype html>), even though browsers don't care.

OwnerDisplayName: nickf

Body:
Am I allowed to add whatever attributes I want to HTML tags such that I can retrieve their value later on using javascript? For example:

...

If that's not going to work, how would you store arbitrary pieces of information like this?

Edit: Since it appears that making up HTML attributes isn't technically valid, I've rephrased the second part of this question into its own question here: How to store arbitrary data for some HTML tags

LastEditorDisplayName: nickf


问:
Android Install on Device Failure [INSTALL_CANCELED_BY_USER]
I'm using Android Studio to connect to run app in my Xiaomi Redmi Note 3G device. My device is already found in the Choose Device Dialog, but I keep getting the [INSTALL_CANCELED_BY_USER] error :

```<code>Waiting for device.
Target device: xiaomi-hm_note_1w-SSE6Y97PFYQCRK45
Uploading file
local path: C:\Users\Anthony\AndroidStudioProjects\UASProject\app\build\outputs\apk\app-debug.apk
remote path: /data/local/tmp/com.si.UASPROJECT
Installing com.si.UASPROJECT
DEVICE SHELL COMMAND: pm install -r "/data/local/tmp/com.si.UASPROJECT"
pkg: /data/local/tmp/com.si.UASPROJECT
Failure [INSTALL_CANCELED_BY_USER]
</code>```

I tried looking for solutions online, but there's no mention of Failure [INSTALL_CANCELED_BY_USER] error.

答: Turn off Miui Optimizations on Developer Settings, then Restart the phone.

Body:
I'm using Android Studio to connect to run app in my Xiaomi Redmi Note 3G device. My device is already found in the Choose Device Dialog, but I keep getting the [INSTALL_CANCELED_BY_USER] error :

Waiting for device.
Target device: xiaomi-hm_note_1w-SSE6Y97PFYQCRK45
Uploading file
local path: C:\Users\Anthony\AndroidStudioProjects\UASProject\app\build\outputs\apk\app-debug.apk
remote path: /data/local/tmp/com.si.UASPROJECT
Installing com.si.UASPROJECT
DEVICE SHELL COMMAND: pm install -r "/data/local/tmp/com.si.UASPROJECT"
pkg: /data/local/tmp/com.si.UASPROJECT
Failure [INSTALL_CANCELED_BY_USER]

I tried looking for solutions online, but there's no mention of Failure [INSTALL_CANCELED_BY_USER] error.


问:
Redirecting non-existing paths to a specific page
I am trying to redirect users who browse paths that doesn't exist to another page I set.
Example:
site.com/dhdhshs will redirect users to a specitic page because the path is not available.
How can I do this, also what kind of file should I create or edit on the webserver?
Thanks</p>

答:
Inside 404 page:</p>

```<code>window.location = "http://www.yoururl.com";
</code>```

Body:
Inside 404 page:

window.location = "http://www.yoururl.com";