我正在寻找一种方法来管理我的WebApp上的路由使用.基本上,我有三个可以共享路由器模式的地方.我可以通过表达语言发送这个模式用于我的观点.
@Controller
public class LoginRuasController
{
@RequestMapping("/system/index")
public String logout(ModelMap model, HttpSession session)
{
return "system/index";
}
@RequestMapping("/system/logout")
public String logout(ModelMap model, HttpSession session)
{
session.setAttribute("xxx", null);
return "redirect:/system/login";
}
}
Run Code Online (Sandbox Code Playgroud)
图案:
/system/index
system/index
redirect:/system/login
Run Code Online (Sandbox Code Playgroud)
观点:
<a href="#{Routes.newuser}">Triple X</a>
Run Code Online (Sandbox Code Playgroud)
最初,RequestMapping请求一个常量值,因此这会产生一个问题,以实现具有静态返回的Route类.有没有解决方案?
我正在尝试在我的工作中运行一名前雇员留下的系统,但我遇到了问题.
如果XSD通过远程访问运行:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd">
Run Code Online (Sandbox Code Playgroud)
它给出了一个未找到的异常:
Failed to read schema document 'http://www.springframework.org/schema/context/spring-context-3.0.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>.
Run Code Online (Sandbox Code Playgroud)
如果XSD通过本地访问运行:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
classpath:org/springframework/beans/factory/xml/spring-beans-3.0.xsd
http://www.springframework.org/schema/tx
classpath:org/springframework/transaction/config/spring-tx-3.0.xsd
http://www.springframework.org/schema/context
classpath:org/springframework/context/config/spring-context-3.0.xsd
http://www.springframework.org/schema/tool
classpath:org/springframework/beans/factory/xml/spring-tool-3.0.xsd">
Run Code Online (Sandbox Code Playgroud)
它给出了这个例外:
C:\Users\claudiomazur>java -jar c:\temp\fin\c.jar
0 [AWT-EventQueue-0] INFO support.ClassPathXmlApplicationContext - Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@4fa52fdf: startup date [Thu Sep 06
11:22:59 BRT …Run Code Online (Sandbox Code Playgroud) 我在内页有问题.它只是将页面识别为iso,但我想要utf-8,我将其声明为默认字符集.我在freemarker配置上尝试了一些修改,但它们没有效果.
为spring-servlet.xml
<bean id="freemarkerConfig" class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
<property name="templateLoaderPath" value="/WEB-INF/pages/"/>
</bean>
Run Code Online (Sandbox Code Playgroud)
template.html
<#macro page>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Cemitério - Prefeitura Municipal de Maringá</title>
</head>
<body>
Usuários
<#nested/>
</body>
</html>
</#macro>
Run Code Online (Sandbox Code Playgroud)
的login.html
<#import "templates/template.html" as t/>
<@t.page>
<#if erroLogin??>
${erroLogin}
</#if>
<form action="entrar" method="post">
<div>
<label>Usuário:</label>
<input type="text" name="usuario" />
<br />
<label>Senha:</label>
<input type="text" name="senha" />
<br />
<input type="submit" name="submit" />
</div>
</form>
</@t.page>
Run Code Online (Sandbox Code Playgroud)
产量

我想了解是否可以使用,如何使用@Autowired Constructor和params进行Bean操作.
@Component
public class Routes
{
private Foo req;
@Autowired
public Routes(Foo req)
{
this.req = req;
}
public String getUrl(String destin)
{
return req.getContextPath() + destin;
}
}
@Component
public class HomeController
{
@Autowired
private Routes routes;
public HomeController(Foo req)
{
String foo = routes.getUrl("something");
}
}
Run Code Online (Sandbox Code Playgroud)
REAL CODE ------编辑---------------异常发生在这一行:String foo = rt.getUrl("caca");
public class AppRun extends HttpServlet {
private static final long serialVersionUID = -3308874705513248491L;
private ApplicationContext context;
@Override
public void service(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, …Run Code Online (Sandbox Code Playgroud) java ×4
spring ×3
spring-mvc ×2
autowired ×1
exception ×1
freemarker ×1
html ×1
javabeans ×1
url-routing ×1
utf-8 ×1
xsd ×1