probleme d'envois un variable vers une page jsp
bonjour;
j'ai un probleme d'envois un variable retourné dans la méthode lireFichier(String fic) de ma classe service.java vers ma page afficher.jsp
voila ma page service.java
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
@Service("personService")
@Transactional
public class PersonService {
protected static Logger logger = Logger.getLogger("service");
public String lireFichier(String fic) throws FileNotFoundException
{
String contenu="";
File f = new File(fic);
if(f.exists())
{
try {
long taille = f.length();
FileInputStream fis = new FileInputStream(f);
BufferedInputStream bis = new BufferedInputStream(fis);
for (long cpt = 0; cpt < taille; cpt++)
contenu+=(char)bis.read();
return contenu;
}
catch (IOException e) {
e.printStackTrace();
}
}
throw new FileNotFoundException();
} |
voila mon controleur maincontroleur.java
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
@Controller
@RequestMapping("/main")
public class MainController {
@RequestMapping(value = "/persons/lireFichier", method = RequestMethod.GET)
public String lire(Model model) {
try {
String fichier = personService.lireFichier("access.log");
model.addAttribute("fichier", fichier);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return "Afficher";
}
} |
je veux afficher cette variable qui est le contenu de mon fichier access.log dans ma page jsp
ce fichier je l'ai mit dans mon projet
voila la page jsp afficher.jsp
Code:
1 2 3 4 5 6 7 8 9 10 11 12
|
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<p>You have ${fichier} </p>
</body>
</html> |
alors lorsque j'execute mon application elle m'affiche que "you have"
que doit je faire ? aidez-moi svp