本文整理汇总了Java中javax.servlet.annotation.WebServlet.name方法的典型用法代码示例。如果您正苦于以下问题:Java WebServlet.name方法的具体用法?Java WebServlet.name怎么用?Java WebServlet.name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.servlet.annotation.WebServlet
的用法示例。
在下文中一共展示了WebServlet.name方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toMappedServlet
import javax.servlet.annotation.WebServlet; //导入方法依赖的package包/类
public MappedServlet toMappedServlet(Servlet servlet) {
WebServlet wsAnnotation = servlet.getClass().getAnnotation(WebServlet.class);
if (wsAnnotation == null) {
throw new IllegalArgumentException(
"Servlet contains no @WebServlet annotation and can not be mapped directly. Wrap it in a MappedServlet instead.");
}
String name = wsAnnotation.name() != null && wsAnnotation.name().length() > 0 ? wsAnnotation.name() : null;
Set<String> urlPatterns = new HashSet<>(asList(wsAnnotation.urlPatterns()));
Map<String, String> initParams = new HashMap<>();
WebInitParam[] paramsArray = wsAnnotation.initParams();
if (paramsArray != null) {
asList(paramsArray).forEach(p -> initParams.put(p.name(), p.value()));
}
return new MappedServlet(servlet, urlPatterns, name, initParams);
}
示例2: printServletInfo
import javax.servlet.annotation.WebServlet; //导入方法依赖的package包/类
protected void printServletInfo() {
Class<?> clazz = this.getClass();
WebServlet servlet = clazz.getAnnotation(WebServlet.class);
if (servlet == null) {
return;
}
String name = servlet.name();
String uri = StringUtils.arrayToDelimitedString(servlet.urlPatterns(), ",");
System.err.println("WebServlet name:" + name + "\turi:" + uri + "\tclass:" + clazz.getName());
}
示例3: createAndRegisterServletBean
import javax.servlet.annotation.WebServlet; //导入方法依赖的package包/类
private void createAndRegisterServletBean(DefaultListableBeanFactory defaultListeableBeanFactory, BeanDefinition bd,
Class<?> beanClass, WebServlet webServlet) {
BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(ServletRegistrationBean.class);
builder.addPropertyValue("servlet", bd);
builder.addPropertyValue("urlMappings", new LinkedHashSet<>(Arrays.asList(webServlet.urlPatterns())));
String beanName = webServlet.name().isEmpty() ? StringUtils.uncapitalize(beanClass.getSimpleName()) : webServlet
.name();
defaultListeableBeanFactory.registerBeanDefinition(beanName, builder.getBeanDefinition());
}
开发者ID:thomasdarimont,项目名称:spring-boot-jee-web-example,代码行数:12,代码来源:JeeComponentsBeanFactoryPostProcessor.java
示例4: addServlet
import javax.servlet.annotation.WebServlet; //导入方法依赖的package包/类
private String addServlet(Servlet servlet) {
Class<?> clz = servlet.getClass();
WebServlet ann = clz.getAnnotation(WebServlet.class);
if (ann == null) {
return null;
}
String name = ann.name();
DynamicSRegistration reg = addServlet(name, servlet);
if (reg == null) {
return null;
}
doParameters(reg, ann.initParams());
reg.addMapping(ann.urlPatterns());
return name;
}
示例5: procesServlets
import javax.servlet.annotation.WebServlet; //导入方法依赖的package包/类
private void procesServlets() {
Consumer<Class<? extends HttpServlet>> c = servlet -> {
WebServlet webServlet = ClassUtils.getAnnotation(servlet, WebServlet.class);
if(webServlet != null) {
ServletDescriptor servletDescriptor = new ServletDescriptor(webServlet.name(),
webServlet.value(), mapUrls(webServlet.urlPatterns()), webServlet.loadOnStartup(),
webServlet.initParams(),webServlet.asyncSupported(),servlet);
webServer.addServlet(servletDescriptor);
}
};
extension.processServlets(c);
}