今天写标签发现问题,不得解,请高手指点标签代码:
[JAVA-Code]
public class CommonTag {
public static List<Module> getModules(int parentId){
System.out.println("一休哥,到这里,就到这里!");
return null;
}
}
[/JAVA-Code]//src/META-INF目录下
[tld-code]
<?xml version="1.0" encoding="UTF-8"?>
<taglib version="2.0" xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd">
<display-name>My Tag Library</display-name>
<tlib-version>1.2</tlib-version>
<short-name>common</short-name>
<uri>/common-tags</uri>
<function>
<name>models</name>
<function-class>com.gwtjs.tags.CommonTag</function-class>
<function-signature>java.util.List getModules(int)</function-signature>
<example>${common:models(0)}</example>
</function>
</taglib>
[/tld-code]报错:
org.apache.jasper.JasperException: /MyTagTest.jsp(2,42) File "/common-tags" not found
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:41)
老是报找不到标签的错
以前把.tld放入src/META-INF目录下就可以直接找到了,不需要在web.xml中定义的。现在非得定义,我实在不想把配置往web.xml里加,请高手指点,谢谢再一个注入的问题:
public class CommonTag {
private static ModuleService moduleService;
public static List<Module> getModules(int parentId){
System.out.println("一休哥,到这里,就到这里! "+(moduleService==null));
return null;
} @Autowired
public void setModuleService(ModuleService moduleService) {
CommonTag.moduleService = moduleService;
}
}@Autowired根本无法注入,能否不用xml配置文件注入??????
[JAVA-Code]
public class CommonTag {
public static List<Module> getModules(int parentId){
System.out.println("一休哥,到这里,就到这里!");
return null;
}
}
[/JAVA-Code]//src/META-INF目录下
[tld-code]
<?xml version="1.0" encoding="UTF-8"?>
<taglib version="2.0" xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd">
<display-name>My Tag Library</display-name>
<tlib-version>1.2</tlib-version>
<short-name>common</short-name>
<uri>/common-tags</uri>
<function>
<name>models</name>
<function-class>com.gwtjs.tags.CommonTag</function-class>
<function-signature>java.util.List getModules(int)</function-signature>
<example>${common:models(0)}</example>
</function>
</taglib>
[/tld-code]报错:
org.apache.jasper.JasperException: /MyTagTest.jsp(2,42) File "/common-tags" not found
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:41)
老是报找不到标签的错
以前把.tld放入src/META-INF目录下就可以直接找到了,不需要在web.xml中定义的。现在非得定义,我实在不想把配置往web.xml里加,请高手指点,谢谢再一个注入的问题:
public class CommonTag {
private static ModuleService moduleService;
public static List<Module> getModules(int parentId){
System.out.println("一休哥,到这里,就到这里! "+(moduleService==null));
return null;
} @Autowired
public void setModuleService(ModuleService moduleService) {
CommonTag.moduleService = moduleService;
}
}@Autowired根本无法注入,能否不用xml配置文件注入??????
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货